JSPÓëSERVLETµÄ¹Øϵ
×ÛÊö£ºJava ServletÊÇJSP¼¼ÊõµÄ»ù´¡£¬¶øÇÒ´óÐ͵ÄWebÓ¦ÓóÌÐòµÄ¿ª·¢ÐèÒªJava ServletºÍJSPÅäºÏ²ÅÄÜÍê³É¡£ÏÖÔÚÐí¶àWeb·þÎñÆ÷¶¼Ö§³ÖServlet£¬¼´Ê¹²»Ö±½ÓÖ§³ÖServletµÄWeb·þÎñÆ÷£¬Ò²¿ÉÒÔͨ¹ý¸½¼þµÄÓ¦Ó÷þÎñÆ÷ºÍÄ£¿éÀ´Ö§³ÖServlet£¬ÕâµÃÒæÓÚJavaµÄ¿çƽ̨ÌØÐÔ¡£ÁíÍ⣬ÓÉÓÚServletÄÚ²¿ÒÔÏ̷߳½Ê½ÌṩÌṩ·þÎñ£¬²»±Ø¶ÔÓÚÿ¸öÇëÇó¶¼Æô¶¯Ò»¸ö½ø³Ì£¬²¢ÇÒÀûÓöàÏ̻߳úÖÆ¿ÉÒÔͬʱΪ¶à¸öÇëÇó·þÎñ£¬Òò´ËServletµÄЧÂʷdz£¸ß¡£
µ«Ëü²¢²»ÊÇûÓÐȱµã£¬ºÍ´«Í³µÄCGI¡¢ISAPI¡¢NSAPI·½Ê½Ïàͬ£¬Java ServletÒ²ÊÇÀûÓÃÊä³öHTMLÓï¾äÀ´ÊµÏÖ¶¯Ì¬ÍøÒ³µÄ£¬Èç¹ûÓÃËüÀ´¿ª·¢Õû¸öÍøÕ¾£¬¶¯Ì¬²¿·ÖºÍ¾²Ì¬Ò³ÃæµÄÕûºÏ¹ý³Ì½«±äµÃÎÞ·¨ÏëÏó¡£Õâ¾ÍÊÇSUN»¹ÒªÍƳöJSPµÄÔÒò¡£
ÈçºÎÕýÈ·Àí½âservlet£¿
servletµÄ»ù±¾¸ÅÄî
Ò»¡¢ServletµÄ½á¹¹
ÔÚ¾ßÌåÕÆÎÕservlet֮ǰ£¬Ðë¶ÔJavaÓïÑÔÓÐËùÁ˽⡣ÎÒÃǼÙÉè¶ÁÕßÒѾ¾ß±¸Ò»¶¨µÄJava»ù´¡¡£ÔÚServlet APIÖÐ×îÖØÒªµÄÊÇServlet½Ó¿Ú£¨interface£©£¬ËùÓеÄservlets¶¼±ØÐëʵÏָýӿڣ¬Í¾¾¶ÓкࣺܶһÊÇÖ±½ÓʵÏָýӿڣ¬¶þÊÇͨ¹ýÀ©Õ¹Àà(class)À´ÊµÏÖ£¬Èç HttpServlet¡£ Õâ¸öServlet½Ó¿ÚÌṩÁËservletÓë¿Í»§¶ËÁªÏµµÄ·½·¨¡£Servlet±àдÕß¿ÉÒÔÔÚËûÃÇ¿ª·¢ servlet³ÌÐòʱÌṩ¸ü¶àһЩ»òËùÓеÄÕâÑù·½·¨¡£
µ±Ò»¸öservlet½ÓÊÕÀ´×Ô¿Í»§¶ËµÄµ÷ÓÃÇëÇó, Ëü½ÓÊÕÁ½¸ö¶ÔÏó£ºÒ»¸öÊÇServletRequest£¬ÁíÍâÒ»¸öÊÇServletResponse¡£Õâ¸öServletRequestÀà¸ÅÀ¨´Ó¿Í»§¶Ëµ½·þÎñÆ÷Ö®¼äµÄÁªÏµ£¬¶ø ServletResponseÀà¸ÅÀ¨´Óservlet·µ»Ø¿Í»§¶ËµÄÁªÏµ¡£
ServletRequest½Ó¿Ú¿ÉÒÔ»ñÈ¡µ½ÕâÑùһЩÐÅÏ¢£¬ÈçÓÉ¿Í»§¶Ë´«Ë͵IJûÊöÃû³Æ£¬¿Í»§¶ËÕýÔÚʹÓõÄÐÒ飬²úÉúÇëÇó²¢ÇÒ½ÓÊÕÇëÇóµÄ·þÎñÆ÷Ô¶¶ËÖ÷»úÃû¡£ËüÒ²Ìṩ»ñÈ¡Êý¾ÝÁ÷µÄServletInputStream, ÕâЩÊý¾ÝÊÇ¿Í»§¶ËÒýÓÃÖÐʹÓÃHTTP POST ºÍ PUT ·½·¨µÝ½»µÄ¡£Ò»¸öServletRequestµÄ×ÓÀà¿ÉÒÔÈÃservlet»ñÈ¡¸ü¶àµÄÐÒéÌØÐÔÊý¾Ý¡£ÀýÈ磺HttpServletRequest °üº¬»ñÈ¡ HTTP-specificÍ·²¿ÐÅÏ¢µÄ·½·¨¡£
ServletResponse½Ó¿Ú¸ø³öÏàÓ¦¿Í»§¶ËµÄservlet·½·¨¡£ËüÔÊÐíservletÉèÖÃÄÚÈݳ¤¶ÈºÍ»ØÓ¦µÄmimeÀàÐÍ£¬²¢ÇÒÌṩÊä³öÁ÷ ServletOutputStream£¬Í¨¹ý±àдÕß¿ÉÒÔ·¢»ØÏàÓ¦µÄÊý¾Ý¡£ServletResponse×ÓÀà¿ÉÒÔ¸ø³ö¸ü¶àprotocol- specificÄÚÈݵÄÐÅÏ¢¡£ ÀýÈ磺HttpServletResponse °üº¬ÔÊÐíservlet ²Ù×÷HTTP-specificÍ·²¿ÐÅÏ¢µÄ·½·¨¡£
ÉÏÃæÓйØÀàºÍ½Ó¿ÚµÄÃèÊö£¬¹¹³ÉÁËÒ»¸ö»ù±¾µÄServlet¿ò¼Ü¡£HTTP servletsÓÐһЩ¸½¼ÓµÄ¿ÉÒÔÌṩsession-tracking capabilitiesµÄ·½·¨¡£servlet±àдÕ
Ïà¹ØÎĵµ£º
ÒÔÇ°ÓÐÌáµ½¹ýÂÒÂëÎÊÌ⣬×î½üÔÚʹÓÃwindow.openʱÓÖ³öÏÖ´ËÀàÎÊÌ⣬ÏÖ½â¾öÈçÏ£º
1£ºÊ¹ÓÃencodeURIComponentº¯Êý¶Ô²ÎÊý½øÐд¦Àí£¬ÀýÈ磺window.open("html.jsp?name=" + encodeUrlComponent(value)));
2£ºÐÞ¸Ätomcat·þÎñÆ÷µÄserver.xmlÎļþÌí¼Ó£ºuseBodyEncodingForURI="true"»òÕß
URIEncoding=" ......
×î½üÔÚ×Ô¼º×öµÄÏîÄ¿ÖÐÐèÒªÓõ½ÔÚÏß±à¼Æ÷,ÔÚÍøÉÏËÑÁËÏ£¬·¢ÏÖÁËckeditor£¬µ±È»ÍøÉÏÓкü¸ÖÖÔÚÏß±à¼Æ÷£¬²»ÖªµÀΪʲôѡÔñÁËckeditor,±¾À´´òËãÓÃFckeditorµÄ£¬µ«ÊÇ¿´µ½ÍøÉÏ»¹ÐèÒªµ¼ÈëºÃ¼¸¸öJAR°ü£¬»¹Òª½øÐÐÒ»¶ÑÅäÖã¬ÓеãÂé·³£¬±¾À´ÏîÄ¿ÖÐÒ²¾ÍÓÃһϣ¬»¹ÒªÄÇôÂé·³µØÈ¥ÅäÖá£
ÓÚÊÇÈ¥ckeditorÍøÕ¾ÏÂÔØÁË×îа汾µÄckeditor£¬ ......
JSP¹²ÓÐÒÔÏÂ9ÖÖ»ù±¾ÄÚÖÃ×é¼þ£¨¿ÉÓëASPµÄ6ÖÖÄÚ²¿×é¼þÏà¶ÔÓ¦£©£º
¡¡1.request Óû§¶ËÇëÇ󣬴ËÇëÇó»á°üº¬À´×ÔGET/POSTÇëÇóµÄ²ÎÊý¡£
2. response ÍøÒ³´«»ØÓû§¶ËµÄ»ØÓ¦ ¡£
3.pageContext ÍøÒ³µÄÊôÐÔÊÇÔÚÕâÀï¹ÜÀí ¡£
4.session ÓëÇëÇóÓйصĻỰÆÚ¡£
5.ap ......
JSP¹²ÓÐÒÔÏÂ6ÖÖ»ù±¾¶¯×÷£º
1.jsp:include£ºÔÚÒ³Ãæ±»ÇëÇóµÄʱºòÒýÈëÒ»¸öÎļþ¡£
2.jsp:useBean£ºÑ°ÕÒ»òÕßʵÀý»¯Ò»¸öJavaBean¡£
3.jsp:setProperty£ºÉèÖÃJavaBeanµÄÊôÐÔ¡£
4.jsp:getProperty£ºÊä³öij¸öJavaBeanµÄÊôÐÔ¡£
5.jsp:forward£º°ÑÇëÇóתµ½ ......