Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : jsp

JSPÄÚÖöÔÏó

JSP µÄÄÚÖöÔÏóÓУºresquest ¡¢response¡¢session¡¢ application ¡¢out¡£ÒÔÏÂÎÒÃǽ«
Ò»Ò»½éÉÜ¡£
response ºÍrequest ¶ÔÏóÊÇJSP µÄÄÚÖöÔÏó½ÏÖØÒªµÄÁ½¸ö£¬ÕâÁ½¸ö¶ÔÏóÌṩÁ˶ԷþÎñ
Æ÷ºÍä¯ÀÀÆ÷ͨÐÅ·½·¨µÄ¿ØÖÆ¡£Ö±½ÓÌÖÂÛÕâÁ½¸ö¶ÔÏóÇ°£¬ÒªÏȶÔHTTP ЭÒé----Word Wide
Webµ×²ãЭÒé×÷¼òµ¥½éÉÜ¡£
Word Wide WebÊÇÔõÑùÔËÐеÄÄØ£¿ÔÚä¯ÀÀÆ÷ÉϼüÈëÒ»¸öÕýÈ·µÄÍøÖ·ºó£¬ÈôÒ»ÇÐ˳Àû£¬
ÍøÒ³¾Í³öÏÖÁË¡£ÀýÈ磬ÔÚä¯ÀÀÆ÷ÊäÈëÀ¸ÖмüÈëhttp://www.yahoo.com£¬Yahoo ÍøÕ¾µÄÖ÷
Ò³¾Í³öÏÖÔÚä¯ÀÀÆ÷´°¿Ú¡£Õâ±³ºóÊÇʲôÔÚÆð×÷Óã¿
ʹÓà ä¯ÀÀÆ÷´ÓÍøÕ¾»ñÈ¡HTML Ò³Ãæʱ£¬ ʵ¼ÊÔÚʹÓÃHypertext Transfer
Protocol(HTTP)¡£ HTTP ЭÒé¹æ¶¨ÁËÐÅÏ¢ÔÚInternet ÉϵĴ«Êä·½·¨£¬Ìرð¹æ¶¨ÁËä¯ÀÀÆ÷
Óë·þÎñÆ÷µÄ½»»¥·½·¨¡£
´ÓÍøÕ¾»ñÈ¡Ò³Ãæʱ£¬ä¯ÀÀÆ÷ÔÚÍøÕ¾ÉÏ´ò¿ªÁËÒ»¸ö¶ÔÍøÂç·þÎñÆ÷µÄÁ¬½Ó£¬²¢·¢³öÇëÇó¡£
·þÎñÆ÷ÊÕµ½ÇëÇóºó»ØÓ¦£¬ËùÒÔHTTP ЭÒé±»³Æ×÷“ÇëÇóºÍÏìÓ¦”ЭÒé¡£
ä¯ÀÀÆ÷ÇëÇóÓÐijÖֽṹ£¬HTTP ÇëÇó°üÀ¨Ò»¸öÇëÇóÐС¢Í·ÓòºÍ¿ÉÄܵÄÐÅÏ¢Ìå¡£×îÆÕͨ
µÄÇëÇóÀàÐÍÊǶÔÒ³ÃæµÄÒ»¸ö¼òµ¥ÇëÇó£¬ÈçÏÂÀý£º
GET/hello.htm HTTP/1.1
Host:www.sina.com.cn
ÕâÊǶÔÍøÕ¾: www.sina.com.cn ÉÏÒ³Ãæhello.htm µÄHTT ......

JSPÄÚÖöÔÏóÖ®request

HTTP ͨÐÅЭÒéÊÇ¿Í»§Óë·þÎñÆ÷Ö®¼äÒ»ÖÖÌá½»£¨ÇëÇó£© ÐÅÏ¢ÓëÏìÓ¦ÐÅÏ¢
£¨request/respone£©µÄͨÐÅЭÒé¡£ÔÚJSP ÖУ¬ÄÚÖöÔÏórequest ·â×°ÁËÓû§Ìá½»µÄÐÅÏ¢£¬
ÄÇô¸Ã¶ÔÏóµ÷ÓÃÏàÓ¦µÄ·½·¨¿ÉÒÔ»ñÈ¡·â×°µÄÐÅÏ¢£¬¼´Ê¹ÓøöÔÏó¿ÉÒÔ»ñÈ¡Óû§Ìá½»µÄÐÅ
Ï¢¡£
¿Í»§Í¨³£Ê¹ÓÃHTML ±íµ¥Ïò·þÎñÆ÷µÄij¸öJSP Ò³ÃæÌá½»ÐÅÏ¢£¬±íµ¥µÄÒ»°ã¸ñʽÊÇ£º
<FORM method= get | post action= “Ìá½»ÐÅÏ¢µÄÄ¿µÄµØÒ³Ãæ”>
Ìá½»ÊÖ¶Î
</FORM>…..
ÆäÖÐ<Form>ÊÇ±íµ¥±êÇ©£¬method È¡Öµget »òpost¡£Get ·½·¨ºÍpost ·½·¨µÄÖ÷ÒªÇø±ð
ÊÇ£ºÊ¹ÓÃget ·½·¨Ìá½»µÄÐÅÏ¢»áÔÚÌá½»µÄ¹ý³ÌÖÐÏÔʾÔÚä¯ÀÀÆ÷µÄµØÖ·À¸ÖУ¬¶øpost ·½·¨
Ìá½»µÄÐÅÏ¢²»»áÏÔʾÔÚµØÖ·À¸ÖС£Ìá½»ÊֶΰüÀ¨£ºÍ¨¹ýÎı¾¿ò¡¢ÁÐ±í¡¢Îı¾ÇøµÈ£¬ÀýÈ磺
<FORM action="tom.jsp" method= “post” >
<INPUT type="text" name="boy" value= “ok” >
<INPUT TYPE="submit" value=" Ëͳö" name= “submit”>
</FORM>
¸Ã±íµ¥Ê¹ÓÃpost·½·¨ÏòÒ³Ãætom.jsp Ìá½»ÐÅÏ¢£¬Ìá½»ÐÅÏ¢µÄÊÖ¶ÎÊÇ£ºÔÚÎı¾¿òÊäÈëÐÅ
Ï¢£¬ÆäÖÐĬÈÏÐÅÏ¢ÊÇ“ok”£»È»ºóµã»÷“Ëͳö”° ......

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 loaded on <%= (new java.util.Date()).toLocaleString() %> -->
ÔÚ¿Í»§¶ËµÄHTMLÔ´´úÂëÖÐÏÔʾΪ:
<!-- This page was loaded on January 1, 2000 -->
ÃèÊö
ÕâÖÖ×¢ÊͺÍHTMLÖкÜÏñ£¬Ò²¾ÍÊÇËü¿ÉÒÔÔÚ"²é¿´Ô´´úÂë"Öп´µ½.
ΨһÓÐЩ²»Í¬µÄ¾ÍÊÇ£¬Äã¿ÉÒÔÔÚÕâ¸ö×¢ÊÍÖÐÓñí´ïʽ£¨Àý×Ó2Ëùʾ).Õâ¸ö±í´ïʾÊDz»¶¨µÄ£¬ÓÉÒ³Ã治ͬ¶ø²»Í¬£¬ÄãÄܹ»Ê¹Óø÷ÖÖ±í´ïʽ£¬Ö»ÒªÊǺϷ¨µÄ¾ÍÐС£¸ü¶àµÄÇë¿´±í´ïʽ
Òþ²Ø×¢ÊÍ
дÔÚJSP³ÌÐòÖУ¬µ«²»ÊÇ·¢¸ø¿Í»§¡£
JSP Óï·¨
<%-- comment --%>
Àý×Ó£º
<%@ page language="java" %>
<html>
<head><title>A Comment Test</title></head>
<body>
<h2>A Test of Comments</h2>
<%-- This comment will not be visible in the page s ......

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


JSP/ServletµÄ±àÂëÔ­Àí
¹Ø¼ü×Ö: jsp, servlet±àÂë
Ê×ÏÈ£¬ËµËµ JSP/Servlet Öеļ¸¸ö±àÂëµÄ×÷Óà
ÔÚ JSP/Servlet ÖÐÖ÷ÒªÓÐÒÔϼ¸ÖÖÉèÖñàÂëµÄ·½Ê½£º
pageEncoding ="UTF-8"
contentType = "text/html;charset=UTF-8"
request.setCharacterEncoding("UTF-8")
response.setCharacterEncoding("UTF-8")
ÆäÖÐÇ°Á½¸öÖ»ÄÜÓÃÓÚJSP ÖУ¬¶øºóÁ½¸ö¿ÉÒÔÓÃÓÚ JSP ºÍ Servlet ÖС£
1¡¢pageEncoding="UTF-8" µÄ×÷ÓÃÊÇÉèÖàJSP ±àÒë³É Servlet Ê±Ê¹ÓõıàÂë
ÖÚËùÖÜÖª£¬JSP ÔÚ·þÎñÆ÷ÉÏÊÇÒªÏȱ»±àÒë³É Servlet µÄ¡£pageEncoding="UTF-8" µÄ×÷ÓþÍÊǸæËß JSP ±àÒëÆ÷ÔÚ½« JSP Îļþ±àÒë³É Servlet Ê±Ê¹ÓõıàÂ롣ͨ³££¬ÔÚ JSP ÄÚ²¿¶¨ÒåµÄ×Ö·û´®£¨Ö±½ÓÔÚ JSP Öж¨Ò壬¶ø²»ÊÇ´Óä¯ÀÀÆ÷Ìá½»µÄÊý¾Ý£©³öÏÖÂÒÂëʱ£¬ºÜ¶à¶¼ÊÇÓÉÓڸòÎÊýÉèÖôíÎóÒýÆðµÄ¡£ÀýÈ磬ÄãµÄJSP ÎļþÊÇÒÔGBK Îª±àÂë±£´æµÄ£¬¶øÔÚJSP ÖÐÈ´Ö¸¶¨pageEncoding="UTF-8" £¬¾Í»áÒýÆðJSP ÄÚ²¿¶¨ÒåµÄ×Ö·û´®ÎªÂÒÂë¡£
ÁíÍ⣬¸Ã²ÎÊý»¹ÓÐÒ»¸ö¹¦ÄÜ£¬¾ÍÊÇÔ ......

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ä¯ÀÀÆ÷»á»°Ïà¹ØµÄ¶ÔÏó£¬Ëü´æÔÚ ......

JSPÖпÉÄÜ»áÅöµ½µÄÎÊÌâ½â´ð

JSPÖпÉÄÜ»áÅöµ½µÄÎÊÌâ½â´ð
À´Ô´:²»Ïê ×÷Õß:ØýÃû ¸üÐÂʱ¼ä: 2009Äê07ÔÂ02ÈÕ µã»÷:
JSPÖпÉÄÜ»áÅöµ½µÄÎÊÌâ½â´ð 
1¡¢ÈçºÎ»ìºÏʹÓÃJspºÍSSI #include?
ÔÚJSPÖпÉÒÔʹÓÃÈçÏ·½Ê½°üº¬´¿HTML£º
< !--#include file="data.inc"-- >
µ«ÊÇÈç¹ûdata.incÖаüº¬JSP CODE £¬ÎÒÃÇ¿ÉÒÔʹÓãº
< %@include file="data.inc"% >
2¡¢ÈçºÎÖ´ÐÐÒ»¸öḬ̈߳²È«µÄJSP?
Ö»ÐèÔö¼ÓÈçÏÂÖ¸Áî
< %@ page isThreadSafe="false" % >
3¡¢JSPÈçºÎ´¦ÀíHTML FORMÖеÄÊý¾Ý?
ͨ¹ýÄÚÖõÄrequest¶ÔÏó¼´¿É£¬ÈçÏ£º
< %
String item = request.getParameter("item");
int howMany = new Integer(request.getParameter("units")).intvalue();
% >
4¡¢ÔÚJSPÈçºÎ°üº¬Ò»¸ö¾²Ì¬Îļþ?
¾²Ì¬°üº¬ÈçÏ£º< %@ include file="copyright.html" % >
¶¯Ì¬°üº¬ÈçÏ£º< jsp:include page="copyright.html" flush="true"/ >
5¡¢ÔÚJSPÖÐÈçºÎʹÓÃ×¢ÊÍ?
Ö÷ÒªÓÐËÄÖз½·¨£º
1¡£< %-- Óë --% >
2¡£//
3¡£/**Óë**/
4¡£< !--Óë-- >
6¡¢ÔÚJSPÖÐÈçºÎÖ´ÐÐä¯ÀÀÖض¨Ïò?
ʹÓÃÈçÏ·½Ê½¼´¿É£ºresponse.sendRedirect("http://ybwen.home.chinare ......
×ܼǼÊý:884; ×ÜÒ³Êý:148; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [2] [3] [4] [5] 6 [7] [8] [9] [10] [11]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ