JSP/ServletµÄURLÖØ¶¨Ïò
1.RequestDispatcher.forward()
ÊÇÔÚ·þÎñÆ÷¶ËÆð×÷ÓÃ,µ±Ê¹ÓÃforward()ʱ,Servlet engine´«µÝHTTPÇëÇó´Óµ±Ç°µÄServlet or JSPµ½ÁíÍâÒ»¸öServlet,JSP »òÆÕͨHTMLÎļþ,Ò²¼´ÄãµÄformÌá½»ÖÁa.jsp,ÔÚa.jspÓõ½ÁËforward()ÖØ¶¨ÏòÖÁb.jsp,´ËʱformÌá½»µÄËùÓÐÐÅÏ¢ÔÚb.jsp¶¼¿ÉÒÔ»ñµÃ,²ÎÊý×Ô¶¯´«µÝ.
µ«forward()ÎÞ·¨Öض¨ÏòÖÁÓÐframeµÄjspÎļþ,¿ÉÒÔÖØ¶¨ÏòÖÁÓÐframeµÄhtmlÎļþ,ͬʱforward()ÎÞ·¨ÔÚºóÃæ´ø²ÎÊý´«µÝ,±ÈÈçservlet?name=frank,ÕâÑù²»ÐÐ,¿ÉÒÔ³ÌÐòÄÚͨ¹ýresponse.setAttribute("name",name)À´´«ÖÁÏÂÒ»¸öÒ³Ãæ.
ÖØ¶¨Ïòºóä¯ÀÀÆ÷µØÖ·À¸URL²»±ä.
Àý:ÔÚservletÖнøÐÐÖØ¶¨Ïò
´úÂëÄÚÈÝͨ³£ÔÚservletÖÐʹÓ㬲»ÔÚjspÖÐʹÓá£
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException ...{
response.setContentType("text/html; charset=gb2312");
ServletContext sc = getServletContext();
RequestDispatcher rd = null;
rd = sc.getRequestDispatcher("/index.jsp"); //¶¨ÏòµÄÒ³Ãæ
rd.forward(request, response);
}
2.response.sendRedirect()
ÊÇÔÚÓû§µÄä¯ÀÀÆ÷¶Ë¹¤×÷,sendRedirect()¿ÉÒÔ´ø²ÎÊý´«µÝ,±ÈÈçservlet?name=frank´«ÖÁϸöÒ³Ãæ,ͬʱËü¿ÉÒÔÖØ¶¨ÏòÖÁ²»Í¬µÄÖ÷»úÉÏ,sendRedirect()¿ÉÒÔÖØ¶¨ÏòÓÐframe.µÄjspÎļþ.
ÖØ¶¨ÏòºóÔÚä¯ÀÀÆ÷µØÖ·À¸ÉÏ»á³öÏÖÖØ¶¨ÏòÒ³ÃæµÄURL
Àý:ÔÚservletÖÐÖØ¶¨Ïò
´úÂëÄÚÈÝ
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException ...{
response.setContentType("text/html; charset=gb2312");
response.sendRedirect("/index.jsp");
}
ÓÉÓÚresponseÊÇjspÒ³ÃæÖеÄÒþº¬¶ÔÏ󣬹ÊÔÚjspÒ³ÃæÖпÉÒÔÓÃresponse.sendRedirect()Ö±½ÓʵÏÖÖØ¶¨Î»¡£
×¢Ò⣺
(1).ʹÓÃresponse.sendRedirectʱ£¬Ç°Ãæ²»ÄÜÓÐHTMLÊä³ö¡£
Õâ²¢²»ÊǾø¶ÔµÄ£¬²»ÄÜÓÐHTMLÊä³öÆäʵÊÇÖ¸²»ÄÜÓÐHTML±»Ë͵½ÁËä¯ÀÀÆ÷
Ïà¹ØÎĵµ£º
µÚÒ»²½£ºÏÂÔØj2sdkºÍtomcat
µ½sun¹Ù·½Õ¾£¨http://java.sun.com/j2se/1.5.0/download.jsp£©ÏÂÔØj2sdk£¬×¢ÒâÏÂÔØ°æ±¾ÎªWindows Offline InstallationµÄSDK£¬Í¬Ê±×îºÃÏÂÔØJ2SE 1.5.0 Documentation£¬È»ºóµ½tomcat¹Ù·½Õ¾µã£¨http://jakarta.apache.org/site/downloads/downloads_tomcat-5.cgi£©ÏÂÔØtomcat£¨ÏÂÔØ×îÐÂ5.5.9°æ±¾µ ......
¼òµ¥½éÉÜJSPÊý¾Ý¿â²Ù×÷µÄ3¸öС¼¼ÇÉ£ºÊý¾ÝÅÅÐò£¬Ö÷/´Ó±í´¦Àí£¬ÊÂÎñ´¦Àí¡£
1¡¡Êý¾ÝÅÅÐò
ÔÚÊý¾Ý¿â¼¼ÊõÖУ¬¿ÉÒÔʹÓÃORDER×Ó¾ä¶Ô²éѯ½á¹û½øÐÐÅÅÐò
[ ORDER BY { order_by_exdivssion[ ASC | DESC]} [ ¸…n ] ]
ÆäÖУ¬order_by_exdivssionÓÃÀ´Ö¸¶¨ÒªÅÅÐòµÄÁУ»ASCÖ¸¶¨°´µÝÔö˳ÐòÅÅÁУ»DESCÖ¸¶¨°´µÝ¼õ˳ÐòÅÅÐò ......
´ÓJSPҳʹͼƬÒÔJPEG±àÂëºó´æ´¢ÔÚÖ¸¶¨Îļþ¼ÐÖС£ÕâÖÖJSPÉÏ´«Í¼Æ¬·½Ê½Óë×é¼þÉÏ´«Ïà±ÈËÆºõ±¿×¾¶øÓÖ²»ÄܶÔÎļþÊôÐÔ½øÐвÙ×÷£¬µ«µÄÈ·¿ÉÒÔÇáËÉʵÏÖJSPÉÏ´«Í¼Æ¬µÄ¹¦ÄÜ¡£
¡¡¡¡uploadimage1.jspʵÏÖ¹¹½¨Ò»¸ö±íµ¥£¬Ìá½»ÓÃÓÚΪ
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
Str ......
http://www.egzcn.com/article/webbc/JSP/2006-03-22/2003.html À´Ô´
ÕªÒª£ºËäÈ»session»úÖÆÔÚwebÓ¦ÓóÌÐòÖб»²ÉÓÃÒѾºÜ³¤Ê±¼äÁË£¬µ«ÊÇÈÔÈ»ÓкܶàÈ˲»Çå³þsession»úÖÆµÄ±¾ÖÊ£¬ÒÔÖÁ²»ÄÜÕýÈ·µÄÓ¦ÓÃÕâÒ»¼¼Êõ¡£±¾ÎĽ«ÏêϸÌÖÂÛsessionµÄ¹¤×÷»úÖÆ²¢ÇÒ¶ÔÔÚJava web applicationÖÐÓ¦ÓÃsession»úÖÆÊ±³£¼ûµÄÎÊÌâ×÷ ......