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

jsp Ìøת·½Ê½

ʹÓÃJSP´óÔ¼ÓÐÏÂÁÐÈýÖÖÌøת·½Ê½£º
1. response.sendRedirect();
2. response.setHeader("Location","");
3. £¼jsp:forward page="" /£¾
¾­¹ýÊÔÑéµÃµ½ÏÂÃæµÄһЩ¹æÔò£º
Ò». response.sendRedirect()
´ËÓï¾äÇ°²»ÔÊÐíÓÐout.flush()£¬Èç¹ûÓÐout.flush()£¬»áÓÐÒì³££º
java.lang.IllegalStateException: Can't sendRedirect() after data has committed to the client.
at com.caucho.server.connection.AbstractHttpResponse.sendRedirect(AbstractHttpResponse.java:558)
...
Ìøתºóä¯ÀÀÆ÷µØÖ·À¸±ä»¯
Èç¹ûÒªÌøµ½²»Í¬Ö÷»úÏ£¬Ìøתºó£¬´ËÓï¾äºóÃæµÄÓï¾ä»á¼ÌÐøÖ´ÐУ¬ÈçͬпªÁËỊ̈߳¬µ«ÊǶÔresponseµÄ²Ù×÷ÒѾ­ÎÞÒâÒåÁË£»
Èç¹ûÒªÌøµ½ÏàͬÖ÷»úÏ£¬´ËÓï¾äºóÃæµÄÓï¾äÖ´ÐÐÍê³Éºó²Å»áÌøת£»
¶þ. response.setHeader("Location","")
´ËÓï¾äÇ°²»ÔÊÐíÓÐout.flush()£¬Èç¹ûÓÐout.flush()£¬Ò³Ãæ²»»áÌøת¡£
Ìøתºóä¯ÀÀÆ÷µØÖ·À¸±ä»¯
´ËÓï¾äºóÃæµÄÓï¾äÖ´ÐÐÍê³Éºó²Å»áÌøת
Èý. £¼jsp:forward page="" /£¾
´ËÓï¾äÇ°²»ÔÊÐíÓÐout.flush()£¬Èç¹ûÓУ¬»áÓÐÒì³££º
java.lang.IllegalStateException: forward() not allowed after buffer has committed.
at com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:134)
at com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:101)
at com.caucho.jsp.PageContextImpl.forward(PageContextImpl.java:836)
...
Ìøתºóä¯ÀÀÆ÷µØÖ·À¸²»±ä£¬µ«ÊÇÖ»ÄÜÌøµ½µ±Ç°Ö÷»úÏÂ
´ËÓï¾äºóÃæµÄÓï¾äÖ´ÐÐÍê³Éºó²Å»áÌøת


Ïà¹ØÎĵµ£º

ÒýÓà JDK 6u12+Tomcat6.0+JSP¾­µäÅäÖÃ(Íêȫ׼ȷÎÞÎó£©

µÚÒ»²½£ºJDKÓëTomcatµÈµÄÏÂÔØÓëÅäÖÃ
    ×îеÄJDKΪ6.0£¨jdk-6u12-windows-i586-p.exe£©£¬tomcatΪ6.0(apache-tomcat-6.0.18.exe)
¿ª·¢»·¾³£º
JDK: jdk-6u12-windows-i586-p.exe
ÏÂÔصØÖ·:http://java.sun.com/javase/downloads/index.jsp
Tomcat:apache-tomcat-6.0.18.exe
ÏÂÔصØÖ·:http://tomcat.a ......

JSPµÄÔËÐÐÄÚÄ»[ת]

JSPµÄÔËÐÐÄÚÄ»
¾­³£ÓÐÅóÓÑÎÊÆð£¬JSPºÍServletÖ®¼äÓÐʲôÇø±ð£¬Á½ÕßÖ®¼äÓÖÓÐʲôÁªÏµ£¿ÆäʵServlet¼¼ÊõµÄ³öÏÖʱ¼äºÜÔ磬Êǵ±Ê±ÎªÁËJavaµÄ·þÎñÆ÷¶ËÓ¦Óöø¿ª·¢µÄ¡£´ó¼Ò¶¼ÖªµÀAppletÊÇÓ¦ÓÃС³ÌÐò£¬Servlet¾ÍÊÇ·þÎñÆ÷¶ËС³ÌÐòÁË¡£µ«ÔÚMicrosoft¹«Ë¾µÄASP¼¼Êõ³öÏÖºó£¬Ê¹Óà Servlet½øÐÐÏìÓ¦Êä³öʱһÐÐÐеÄÊä³öÓï¾ä¾ÍÏԵ÷dz£±¿×¾£ ......

jsp request sessionµÈ¶ÔÏó Ïê½â


jsp request session
µÈ¶ÔÏó

Ïê½â
 
תÕß×¢£º´ËÎÄ×ܽá½ÏΪÏêϸ£¬ÖµµÃ²Î¿¼¡£µ«²¿·ÖÄÚÈݾ­¹ýÕûÀí£¬ÒÔÏÂÊÇÕýÎÄ¡£
 
1.request
¶ÔÏó
 
ÕâÁ½¸ö¶ÔÏóÊÇASPËùÌṩµÄÄÚÖöÔÏóÖÐ×î³£ÓõÄÁ½¸ö¡£ÔÚä¯ÀÀÆ÷£¨»òÆäËûÓû§´úÀí£©ºÍWeb·þÎñÆ÷Ö®¼ä£¬ÇëÇóÓëÏìÓ¦Öз¢ÉúµÄÐÅÏ¢½»Á÷¿ÉÒÔͨ¹ýASPÖеÄÁ½¸öÄÚÖöÔÏóÀ´½øÐÐ ......

TomcatÔõô´¦ÀíJSPÒ³Ãæ

²úÉú״̬ÏìÓ¦Âë
100¡«199£º±íʾ·þÎñ¶Ë³É¹¦½ÓÊÕÇëÇ󣬵«ÒªÇó¿Í»§¶Ë¼ÌÐøÌá½»ÏÂÒ»´ÎÇëÇó²ÅÄÜÍê³ÉÈ«²¿´¦Àí¹ý³Ì¡£
200¡«299£º±íʾ·þÎñ¶ËÒѾ­³É¹¦½ÓÊÕÇëÇ󣬲¢Íê³ÉÁËÈ«²¿´¦Àí¹ý³Ì¡£
300¡«399£º±íʾ¿Í»§¶ËÇëÇóµÄ×ÊÔ´ÒѾ­ÒƵ½Á˱ðµÄλÖ㬲¢Ïò¿Í»§¶ËÌṩһ¸öеĵØÖ·£¬Ò»°ãÕâ¸öеØÖ·ÓÉHTTPÏìÓ¦ÏûϢͷµÄLocation×Ö¶ÎÖ¸¶¨¡£
400¡ ......

ASPÓëJSP ¹ØÓÚÒ³ÃæµÄÊäÈëºÍÊä³öµÄÎÊÌâ

Ò³ÃæµÄÊäÈëºÍÊä³öÉæ¼°µ½ÁËRequestºÍResponse,ÓÉÓÚËûÃǺÍJspÖеÄÏàËÆ,
ÏÂÃæÎÒÃǽøÐÐÏêϸµÄ½â¶Á£º
JSPÖУº
    ÔÚ¶¯Ì¬ÍøÒ³¿ª·¢ÖУ¬HTML±íµ¥ÊÇÓëÓû§½»»¥ÐÅÏ¢µÄÖ÷ÒªÊֶΡ£
    ʹÓÃJSP´¦Àí±íµ¥ÇëÇóʱ£¬Ò»°ã×ñÑ­ÕâÑùÒ»ÖÖģʽ£¬Ê×ÏÈ£¬Óû§Í¨¹ý±íµ¥¿Ø¼þÊäÈë²¢Ìá½»ÐÅÏ¢;½Ó×Å£¬JSPÒ³Ãæ»ñµÃ±íµ¥Êý ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ