Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

webʵÑ鱨¸æ——JSP¶¯Ì¬ÍøÒ³±à³Ì

ʵÑ鱨¸æ
Ò». »ù±¾Ë¼Â·¼°ÊµÑé½á¹û£¨¼Ç¼¸÷ÖÖÔËÐÐÇé¿ö»òÒ³ÃæµÄÔËÐÐЧ¹û£©£»
1¡¢Ê¹ÓÃTOMCAT·þÎñÆ÷ÅäÖÃjspÓ¦ÓÃ
1£©´ò¿ªTOMCAT/webapps×ÓĿ¼£¬´´½¨Ò»webÓ¦Óã¨Èçmyweb£©£¬½«example0.jspÓëexample1.jspÎļþ¸´ÖÆÈëÄÚ£¬²¢ÔÚ¸ÃĿ¼ÏÂÉèÖÃWEB-INFĿ¼¼°web.xmlÅäÖÃÎļþ£»
2£©ÔÚä¯ÀÀÆ÷µØÖ·À¸ÊäÈëhttp://localhost:8080/myweb/example0.jsp £¬»Ø³µºó£¬²é¿´example0.jspÍøҳЧ¹û  
ÔËÐнá¹û£º
 
3£©ÔÚä¯ÀÀÆ÷µØÖ·À¸ÊäÈëhttp://localhost:8080/myweb/example1.jsp £¬»Ø³µºó£¬²é¿´example1.jspÍøҳЧ¹û£»
2¡¢±àд»ù±¾JSP¶¯Ì¬ÍøÒ³
1£©´´½¨date.jsp£¬Ò³ÃæÔËÐÐЧ¹ûÓ¦¸ù¾Ýµ±Ç°ÏµÍ³Ê±¼äÊä³ö£º
“£¨ÉÏÎç¡¢ÏÂÎç¡¢ÍíÉÏ£©ºÃ£¡   ½ñÌìÊÇ__   __Äê_   ___ÔÂ__ __ÈÕ£¬ÐÇÆÚ£¨Ò»~ÈÕ£©¡£”£»
   [²Î¿¼´úÂ룺Date today=new Date(); thisYear= 1900+today.getYear();]
Ô´´úÂ룺
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
    <base href="<%=basePath%>">
   
    <title>Date</title>
 
 
 </head>
 
 <body>
 <%
    //CalendarÕâÀàÀ´±íʾʱ¼ä£¬ÏÖÔÚ¸ü³£Óã¬ËùÒÔÎÒÑ¡ÔñʹÓÃÁËÕâ¸ö
    Calendar date = Calendar.getInstance();//µÃµ½Calendar¶ÔÏ󣬲»Äܼòµ¥µØÓÃnewÀ´´´½¨
    int year = date.get(Calendar.YEAR);//Äê
    int month = date.get(Calendar.MONTH)+1;//Ô£¬Ðè+1À´µ÷Õû
    int day = date.get(Calendar.DATE);//ÈÕ
    int weekDay = date.get(Calendar.DAY_OF_WEEK)-1;//ÐÇÆÚ¼¸
    String[] sweekDay = {"ÈÕ","Ò»","¶þ","Èý","ËÄ","Îå","Áù"};//½²Ó¢ÎıíʾΪÖÐÎÄ
    int hour = date.get(Calendar.HOUR_OF_DAY);//µÃµ½ÏÖÔÚÊǼ¸µã
    String weclome =


Ïà¹ØÎĵµ£º

jsp¾ÅÖÖÄÚÖöÔÏó

request, reponse, out, session, application, config, pagecontext, page, exception.

Ò».request¶ÔÏ󣺸öÔÏó·â×°ÁËÓû§Ìá½»µÄÐÅÏ¢£¬Í¨¹ýµ÷ÓøöÔÏóÏàÓ¦µÄ·½·¨¿ÉÒÔ»ñÈ¡·â×°µÄÐÅÏ¢£¬¼´Ê¹ÓøöÔÏó¿ÉÒÔ»ñÈ¡Óû§Ìá½»ÐÅÏ¢¡£
1.Request¶ÔÏó¿ÉÒÔʹÓÃgetParameter(string s)·½·¨»ñÈ¡¸Ã±íµ¥Í¨¹ýtextÌá½»µÄÐÅÏ¢¡£È磺
Requ ......

JSPÖеÄpageEncodingºÍ contentTypeÊôÐÔ

JSPÖеÄpageEncodingºÍ contentTypeÊôÐÔ
¹ØÓÚJSPÒ³ÃæÖеÄpageEncodingºÍcontentTypeÁ½ÖÖÊôÐÔµÄÇø±ð£º
pageEncodingÊÇjspÎļþ±¾ÉíµÄ±àÂë contentTypeµÄcharsetÊÇÖ¸·þÎñÆ÷·¢Ë͸ø¿Í»§¶ËʱµÄÄÚÈݱàÂë JSPÒª¾­¹ýÁ½´ÎµÄ“±àÂ딣¬µÚÒ»½×»áÓÃpageEncoding£¬µÚ¶þ½×¶Î»áÓÃutf-8ÖÁutf-8£¬µÚÈý½×¶Î¾ÍÊÇÓÉTomcat³öÀ´µÄÍøÒ³ ......

java³ÌÐòÖе÷ÓÃÉãÏñͷʵÏÖjsp³ÌÐòÉãÏñÍ·Êý¾Ý²É¼¯

½üÆÚµÄÒ»¸öÏîÄ¿ÐèҪʵÏÖÉãÏñͷͼÏñ²É¼¯£¬¾­¹ýһϵÁеÄÕÛÌÚÒÔºó£¬ÖÕÓÚʵÏÖÁËÕâ¸ö¹¦ÄÜ£¬ÏÖÕûÀíһϡ£
±¾Éí¾Íjava¼¼ÊõÀ´Ëµ£¬ÒªÊµÏÖÉãÏñÍ·¶þ´Î¿ª·¢£¬²É¼¯ÉãÏñͷͼƬ£¬ÐèҪʹÓõ½JMF£¬JMFÊʺÏʹÓÃÔÚj2se³ÌÐòµ±ÖУ¬ÎÒÐèÒªÔÚweb³ÌÐòÖе÷ÓÃÉãÏñÍ·£¬ºÜÃ÷ÏÔJMFÊǸ㲻¶¨ÁË£¬Ïë¹ýдһ¸öapplet³ÌÐò£¬Ö»ÊÇÄǶ«Î÷ÒªÇó¿Í»§¶Ë±ØÐëÒªÓÐjre»·¾ ......

JSPÖеÄCookieʹÓÃ

Cookie¸ÅÄî:
    CookieµÄ¸ñʽʵ¼ÊÉÏÊÇÒ»¶Î´¿Îı¾ÐÅÏ¢, ÓÉ·þÎñÆ÷Ëæ×ÅÍøÒ³Ò»Æð·¢Ë͵½¿Í»§¶Ë, ²¢±£´æÔÚ¿Í»§¶ËÓ²ÅÌÖÐÖ¸¶¨µÄĿ¼µÄ. ´ó¼Ò¶¼´«ËµCookie»áÔì³ÉÑÏÖصݲȫÍþвʲôµÄ, Æäʵ²»ÊÇÕâô»ØÊÂÇé. ·þÎñÆ÷¶ÁÈ¡CookieµÄʱºò, Ö»Äܹ»¶ÁÈ¡µ½Õâ¸ö·þÎñÆ÷Ïà¹ØµÄÐÅÏ¢. ¶ø ......

jspÖÐÏÔʾµ±Ç°ÏµÍ³Ê±¼ä

1¡¢<%=(new   java.util.Date()).toLocaleString()%>
2¡¢<script   language= "javascript ">
var   today=new   Date()
var   month=today.getMonth()+1
document.write(today.getYear()+ "Äê "+month+ "ÔÂ "+today.getDate()+ "ÈÕ ")     
  ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ