JSPÖÐÒ³Ãæ×Ô¶¯¶¨Ê±Ë¢ÐÂ
1.JSPÖÐÒ³Ã涨ʱˢÐÂ
Java
´úÂë < type="application/x-shockwave-flash" width="14" height="15" src="http://penghuaiyi.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" src="http://penghuaiyi.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=%3C%25%0A%20%20%20%2F%2F%E9%A1%B5%E9%9D%A2%E6%AF%8F%E9%9A%9430%E7%A7%92%E8%87%AA%E5%8A%A8%E5%88%B7%E6%96%B0%E4%B8%80%E9%81%8D%20%20%20%20%0A%20%20%20response.setHeader(%22refresh%22%2C%2230%22)%3B%0A%25%3E%0A" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" height="15" width="14">
<%
//Ò³Ãæÿ¸ô30Ãë×Ô¶¯Ë¢ÐÂÒ»±é
response.setHeader("refresh"
,
"30"
);
%>
<%
//Ò³Ãæÿ¸ô30Ãë×Ô¶¯Ë¢ÐÂÒ»±é
response.setHeader("refresh","30");
%>
2.JSPÖÐÒ³Ã涨ʱˢÐÂÖÁÁíÒ»¸öÖ¸¶¨Ò³Ãæ
Java
´úÂë < type="application/x-shockwave-flash" width="14" height="15" src="http://penghuaiyi.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" src="http://penghuaiyi.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=%3C%25%0A%20%20%20%20%2F%2F%E9%A1%B5%E9%9D%A2%E6%AF%8F%E9%9A%9430%E7%A7%92%E8%87%AA%E5%8A%A8%E9%93%BE%E6%8E%A5%E8%87%B3%E5%8F%A6%E4%B8%80%E9%A1%B5%E9%9D%A2%0A%20%20%20%20response.setHeader(%22refresh%22%2C%2230%3BURL%3Dhttp%3A%2F%2Fwww.sina.com%22)%3B%0A%25%3E%0A%0A%0A" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" height="15" width="14">
<%
//Ò³Ãæÿ¸ô30Ãë×Ô¶¯Á´½ÓÖÁÁíÒ»Ò³Ãæ
response.setHeader("refresh"
,
"30;URL=http://www.sina.com"
);
%>
<%
//Ò³Ãæÿ¸ô30Ãë×Ô¶¯Á´½ÓÖÁÁíÒ»Ò³Ãæ
respo
Ïà¹ØÎĵµ£º
ת×Ô£ºhttp://www.centospub.com/make/servlet.html
Ç°¡¡¡¡ÑÔ
¡¡¡¡Ëùν Java Servlet £¬ÊÇÖ¸Óà Java ÓïÑÔ£¬ÊµÏÖ¶¯Ì¬ÍøÒ³µÄ´´½¨µÄ¹¦ÄÜ£¬Ò»°ã°Ñ¼òµ¥µÄ°ÑËü³ÆΪ“Servlet”£¨ÎÞÖÐÎÄÒëÎÄ£©µÄÇé¿ö±È½Ï³£¼û¡£ºÍËü´¦ÓÚͬµÈÀà±ðµÄ¼¼Êõ»¹ÓÐÎÒÃÇÖªµÀµÄPerl¡¢PHP¡¢ASPµÈµÈ¡£ServletËãÊÇJ2EEÖеÄÒ»²¿·Ö£¬ËùÒÔÔÚÆóÒµÓ¦Ó÷½Ãæ ......
request, reponse, out, session, application, config, pagecontext, page, exception.
Ò».request¶ÔÏ󣺸öÔÏó·â×°ÁËÓû§Ìá½»µÄÐÅÏ¢£¬Í¨¹ýµ÷ÓøöÔÏóÏàÓ¦µÄ·½·¨¿ÉÒÔ»ñÈ¡·â×°µÄÐÅÏ¢£¬¼´Ê¹ÓøöÔÏó¿ÉÒÔ»ñÈ¡Óû§Ìá½»ÐÅÏ¢¡£
1.Request¶ÔÏó¿ÉÒÔʹÓÃgetParameter(string s)·½·¨»ñÈ¡¸Ã±íµ¥Í¨¹ýtextÌá½»µÄÐÅÏ¢¡£È磺
Requ ......
Ò»¡¢JSP¼ò½é
JSP (Java Server Pages)ÊÇ·þÎñÆ÷¶ËµÄ½Å±¾ÓïÑÔ£¬ÊÇÒ»ÖÖÔÚHTMLÒ³ÃæÖмÓÈëJavaÓïÑÔ¶øÉú³É¶¯Ì¬Ò³ÃæµÄ¼¼Êõ£º¼ÓÈëÁËеıêÇ©£¨<%£¬%>£¬…£©¡£
JSPÊÇÒÔJavaºÍServletΪ»ù´¡¿ª·¢¶ø³ÉµÄ¶¯Ì¬ÍøÒ³Éú³É¼¼Êõ£¬ËüµÄµ×²ãʵÏÖÊÇJava Servlet¡£
JSPÒ³ÃæÓÉHTML´úÂëºÍǶÈëÆäÖеÄJava´úÂëËù×é³É¡£·þÎñÆ÷ÔÚÒ³Ãæ±»¿Í» ......
ÔÚJSPÖй²ÏíÊý¾Ý£¬´óÌå·ÖΪ2ÖÐÇé¿ö¡£Ò»ÊÇÔÚͬһ¸öÓû§µÄ²»Í¬Ò³ÃæÖ®¼ä¹²ÏíÊý¾Ý£¬¶þÊÇÔÚ²»Í¬µÄÓû§Ö®¼ä¹²ÏíÊý¾Ý.
¶ÔÓÚͬһ¸öÓû§µÄ»á»°£¬ÒªÏëÔÚ²»Í¬µÄÒ³ÃæÖ®¼ä¹²ÏíÊý¾Ý£¬¿ÉÓÐÒÔϼ¸ÖÖÑ¡Ôñ
¡ñ°ÑÊý¾Ý±£´æÔÚSessionÖУ¨ÕâÊǷdz£³£¼ûµÄ·½Ê½£©¡£
¡ñͨ¹ýCookie.
¡ñͨ¹ýÒþº¬µÄ±íµ¥°ÑÊý¾Ý´«µ½ÏÂÒ»¸öÒ³Ãæ¡£
¡ñͨ¹ýServletContext¶ ......
//ÏÂÃ棬´ÓÇëÇóÖеõ½ÊôÐÔ ÎªÒ»¸ö À࣬£¬»áÅжÏÊÇ·ñΪnull£¬£¬ÈçΪnullÔòʵÀý»¯
// id Öµ Ï൱ÓÚ class µÄ ¶ÔÏóÃû
<jsp:useBean id="order" class="com.entity.Order" scope="request" />
<==>
<%
Order order=(Order)request.getAttribute("order");
if(order==null)
  ......