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

JSP¾Å´óÄÚÖöÔÏó¼°Ëĸö×÷ÓÃÓò½éÉÜ

JSP¾Å´ó¶ÔÏó£º
ÄÚÖöÔÏó£¨ÓÖ½ÐÒþº¬¶ÔÏó£¬ÓÐ9¸öÄÚÖöÔÏó£©:²»ÐèÒªÔ¤ÏÈÉùÃ÷¾Í¿ÉÒÔÔڽű¾´úÂëºÍ±í´ïʽÖÐËæÒâʹÓÃ
1-out:
javax.servlet.jsp.JspWriterÀàÐÍ£¬´ú±íÊä³öÁ÷µÄ¶ÔÏó¡£×÷ÓÃÓòΪpage£¨Ò³ÃæÖ´ÐÐÆÚ£©
request£ºjavax.servlet.ServletRequestµÄ×ÓÀàÐÍ£¬´Ë¶ÔÏó·â×°ÁËÓÉWEBä¯ÀÀÆ÷»òÆäËü¿Í»§¶ËÉú³ÉµØHTTP
ÇëÇóµÄϸ½Ú£¨²ÎÊý£¬ÊôÐÔ£¬Í·±êºÍÊý¾Ý£©¡£×÷ÓÃÓòΪrequest(Óû§ÇëÇóÆÚ£©¡£
·½·¨Óɿɲ鿴API
response£ºjavax.servlet.ServletResponseµÄ×ÓÀàÐÍ£¬´Ë¶ÔÏó·â×°ÁË·µ»Øµ½HTTP¿Í»§¶ËµÄÊä³ö£¬ÏòÒ³Ãæ
×÷ÕßÌṩÉèÖÃÏìӦͷ±êºÍ״̬ÂëµÄ·½Ê½¡£¾­³£ÓÃÀ´ÉèÖÃHTTP±êÌ⣬Ìí¼Ócookie£¬ÉèÖÃÏìÓ¦ÄÚÈݵÄÀàÐͺÍ×´
̬£¬·¢ËÍHTTPÖض¨ÏòºÍ±àÂëURL¡£×÷ÓÃÓòΪpage£¨Ò³ÃæÖ´ÐÐÆÚ£©¡£
pageContext£ºjavax.servlet.jsp.PageContext£¨³éÏóÀࣩÀàÐÍ£¬×÷ÓÃÓòΪpage£¨Ò³ÃæÖ´ÐÐÆÚ£©¡£´Ë¶ÔÏó
ÌṩËùÓÐËĸö×÷ÓÃÓò²ã´ÎµÄÊôÐÔ²éѯºÍÐÞ¸ÄÄÜÁ¦£¬ËüÒ²ÌṩÁËת·¢ÇëÇóµ½ÆäËü×ÊÔ´ºÍ°üº¬ÆäËû×ÊÔ´µÄ·½·¨
£º
¸Ã¶ÔÏóµÄ·½·¨¶¼ÊdzéÏó·½·¨
session£ºjavax.servlet.http.HttpSessionÀàÐÍ£¬Ö÷ÒªÓÃÓÚ¸ú×Ù¶Ô»°¡£×÷ÓÃÓòsession(»á»°ÆÚ—£©¡£
HttpSessionÊÇÒ»¸öÀàËƹþÏ£±íµÄÓëµ¥Ò»WEBä¯ÀÀÆ÷»á»°Ïà¹ØµÄ¶ÔÏó£¬Ëü´æÔÚÓÚHTTPÇëÇóÖ®¼ä£¬¿ÉÒÔ´æ´¢ÈÎ
ºÎÀàÐ͵ÄÃüÃû¶ÔÏó¡£
Èç¹û²»ÐèÒªÔÚÇëÇóÖ®¼ä¸ú×ٻỰ¶ÔÏ󣬿ÉÒÔͨ¹ýÔÚpageÖ¸ÁîÖÐÖ¸¶¨session="false"
ÐèÒª¼ÇסµÄÊÇpageContext¶ÔÏóÒ²¿ÉÒÔÓësession.getAttribute(),session.setAttribute()Ò»ÑùµÄ·½Ê½È¡
µÃ²¢ÉèÖûỰÊôÐÔ¡£
application£ºjavax.servlet.ServletContextÀàÐÍ£¬servletµÄ»·¾³Í¨¹ýµ÷ÓÃgetServletConfig
().getContext()·½·¨»ñµÃ¡£×÷ÓÃÓòÊÇapplication(Õû¸ö³ÌÐòÔËÐÐÆÚ£©¡£ËüÌṩÁ˹ØÓÚ·þÎñÆ÷°æ±¾£¬Ó¦ÓÃ
¼¶³õʼ»¯²ÎÊýºÍÓ¦ÓÃÄÚ×ÊÔ´¾ø¶Ô·¾¶£¬×¢²áÐÅÏ¢µÄ·½Ê½
config£ºjavax.servlet.ServletConfig,×÷ÓÃÓòΪpage£¨Ò³ÃæÖ´ÐÐÆÚ£©
exception:java.lang.Throwable,ͨ¹ýJSP´íÎóÒ³ÃæÖÐÒ»¸öcatch¿éÒѾ­Òæ³öµ«Ã»ÓⶻñµÄ
java.lang.ThrowableµÄÈÎÒâʵÀý£¬´«ÏòÁËerrorPageµÄURI¡£×÷ÓÃÓòΪpage£¨Ò³ÃæÖ´ÐÐÆÚ£©¡£×¢Òâ
exceptionÖ»ÓÐÔÚpageÖ¸ÁîÖоßÓÐÊôÐÔisErrorPage="true"ʱ²ÅÓÐЧ¡£
page:java.lang.ObjectÀàÐÍ£¬Ö¸ÏòÒ³Ãæ×ÔÉíµÄ·½Ê½¡£×÷ÓÃÓòΪpage£¨Ò³ÃæÖ´ÐÐÆÚ
JSPÖоŴóÄÚÖöÔÏóΪ£º
request ÇëÇó¶ÔÏó¡¡ ÀàÐÍ javax.servlet.ServletRequest ×÷ÓÃÓò Request
response ÏìÓ¦¶ÔÏó ÀàÐÍ javax.servlet.SrvletResponse ×÷ÓÃÓò Page
pageContex


Ïà¹ØÎĵµ£º

5ÔÂ19ÈÕ JSP»ù´¡

1.essionÄڵĴæ·ÅµÄÊǶÔÏóµÄÒýÓÃ,ËùÒÔÐÞ¸ÄÄÚÖöÔÏóºó,²»ÐèÒªÖØзÅÖõ½sessionÖÐ
2.ÅäÖÃContext³õʼ»¯²ÎÊý
<Context-param>
<param-name></paran-name>
<param-value></param-value>
<Context-param>
this.getServletContext().getInitParameter(arg0);
--------------------- ......

´«ÖDz¥¿ÍJavaÅàѵ JSPÄÚÖöÔÏó¡¢Òì³£´¦ÀíÓëÂÒÂëÎÊÌâ

JSP¾Å´óÄÚÖöÔÏó£º
       1.ÓëServletÓйصÄÒþº¬µÄ¶ÔÏó
          (1)page  page¶ÔÏó¶ÔÓ¦JavaÖеĹؼü×Öthis,Ëü´ú±íµ±Ç°JSPÒ³Ãæ
          (2)config  Config¶ÔÏóʹÓÃWebÈÝÆ ......

JSPÄÚÖöÔÏóÖ®request

HTTP ͨÐÅЭÒéÊÇ¿Í»§Óë·þÎñÆ÷Ö®¼äÒ»ÖÖÌá½»£¨ÇëÇó£© ÐÅÏ¢ÓëÏìÓ¦ÐÅÏ¢
£¨request/respone£©µÄͨÐÅЭÒé¡£ÔÚJSP ÖУ¬ÄÚÖöÔÏórequest ·â×°ÁËÓû§Ìá½»µÄÐÅÏ¢£¬
ÄÇô¸Ã¶ÔÏóµ÷ÓÃÏàÓ¦µÄ·½·¨¿ÉÒÔ»ñÈ¡·â×°µÄÐÅÏ¢£¬¼´Ê¹ÓøöÔÏó¿ÉÒÔ»ñÈ¡Óû§Ìá½»µÄÐÅ
Ï¢¡£
¿Í»§Í¨³£Ê¹ÓÃHTML ±íµ¥Ïò·þÎñÆ÷µÄij¸öJSP Ò³ÃæÌá½»ÐÅÏ¢£¬±íµ¥µÄÒ»°ã¸ñʽÊÇ£º ......

JSPÓï·¨Ïê½â

HTML ×¢ÊÍ
ÔÚ¿Í»§¶ËÏÔʾһ¸ö×¢ÊÍ.
JSP Óï·¨
<!-- comment [ <%= expression %> ] -->
Àý×Ó 1
<!-- This file displays the user login screen -->
ÔÚ¿Í»§¶ËµÄHTMLÔ´´úÂëÖвúÉúºÍÉÏÃæÒ»ÑùµÄÊý¾Ý£º
<!-- This file displays the user login screen -->
Àý×Ó 2
<!-- This page was ......

JSP/ServletµÄ±àÂëÔ­Àí


JSP/ServletµÄ±àÂëÔ­Àí
¹Ø¼ü×Ö: jsp, servlet±àÂë
Ê×ÏÈ£¬ËµËµ JSP/Servlet Öеļ¸¸ö±àÂëµÄ×÷Óà
ÔÚ JSP/Servlet ÖÐÖ÷ÒªÓÐÒÔϼ¸ÖÖÉèÖñàÂëµÄ·½Ê½£º
pageEncoding ="UTF-8"
contentType = "text/html;charset=UTF-8"
request.setCharacterEncoding("UTF-8")
response.setCharacterEncodin ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ