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

JSPÄÚÖöÔÏó(9¸ö³£ÓõÄÄÚÖöÔÏó)

JSPÄÚÖöÔÏó(9¸ö³£ÓõÄÄÚÖöÔÏó)  
 1.request¶ÔÏó 
¿Í»§¶ËµÄÇëÇóÐÅÏ¢±»·â×°ÔÚrequest¶ÔÏóÖУ¬Í¨¹ýËü²ÅÄÜÁ˽⵽¿Í»§µÄÐèÇó£¬È»ºó×ö³öÏìÓ¦¡£ËüÊÇHttpServletRequestÀàµÄʵÀý¡£ 
ÐòºÅ ·½ ·¨ ˵ Ã÷ 
1 object getAttribute(String name) ·µ»ØÖ¸¶¨ÊôÐÔµÄÊôÐÔÖµ 
2 Enumeration getAttributeNames() ·µ»ØËùÓпÉÓÃÊôÐÔÃûµÄö¾Ù 
3 String getCharacterEncoding() ·µ»Ø×Ö·û±àÂ뷽ʽ 
4 int getContentLength() ·µ»ØÇëÇóÌåµÄ³¤¶È£¨ÒÔ×Ö½ÚÊý£© 
5 String getContentType() µÃµ½ÇëÇóÌåµÄMIMEÀàÐÍ 
6 ServletInputStream getInputStream() µÃµ½ÇëÇóÌåÖÐÒ»ÐеĶþ½øÖÆÁ÷ 
7 String getParameter(String name) ·µ»ØnameÖ¸¶¨²ÎÊýµÄ²ÎÊýÖµ 
8 Enumeration getParameterNames() ·µ»Ø¿ÉÓòÎÊýÃûµÄö¾Ù 
9 String[] getParameterValues(String name) ·µ»Ø°üº¬²ÎÊýnameµÄËùÓÐÖµµÄÊý×é 
10 String getProtocol() ·µ»ØÇëÇóÓõÄЭÒéÀàÐͼ°°æ±¾ºÅ 
11 String getScheme() ·µ»ØÇëÇóÓõļƻ®Ãû,Èç:http.https¼°ftpµÈ 
12 String getServerName() ·µ»Ø½ÓÊÜÇëÇóµÄ·þÎñÆ÷Ö÷»úÃû 
13 int getServerPort() ·µ»Ø·þÎñÆ÷½ÓÊÜ´ËÇëÇóËùÓõĶ˿ںŠ
14 BufferedReader getReader() ·µ»Ø½âÂë¹ýÁ˵ÄÇëÇóÌå 
15 String getRemoteAddr() ·µ»Ø·¢ËÍ´ËÇëÇóµÄ¿Í»§¶ËIPµØÖ· 
16 String getRemoteHost() ·µ»Ø·¢ËÍ´ËÇëÇóµÄ¿Í»§¶ËÖ÷»úÃû 
17 void setAttribute(String key,Object obj) ÉèÖÃÊôÐÔµÄÊôÐÔÖµ 
18 String getRealPath(String path) ·µ»ØÒ»ÐéÄâ·¾¶µÄÕæʵ·¾¶ 
 2.response¶ÔÏó 
response¶ÔÏó°üº¬ÁËÏìÓ¦¿Í»§ÇëÇóµÄÓйØÐÅÏ¢£¬µ«ÔÚJSPÖкÜÉÙÖ±½ÓÓõ½Ëü¡£ËüÊÇHttpServletResponseÀàµÄʵÀý¡£ 
ÐòºÅ ·½ ·¨ ˵ Ã÷ 
1 String getCharacterEncoding() ·µ»ØÏìÓ¦ÓõÄÊǺÎÖÖ×Ö·û±àÂë 
2 ServletOutputStream getOutputStream() ·µ»ØÏìÓ¦µÄÒ»¸ö¶þ½øÖÆÊä³öÁ÷ 
3 PrintWriter getWriter() ·µ»Ø¿ÉÒÔÏò¿Í»§¶ËÊä³ö×Ö·ûµÄÒ»¸ö¶ÔÏó 
4 void setContentLength(int len) ÉèÖÃÏìӦͷ³¤¶È 
5 void setContentType(String type) ÉèÖÃÏìÓ¦µÄMIMEÀàÐÍ 
6 sendRedirect(java.lang.String location) ÖØж¨Ïò¿Í»§¶ËµÄÇëÇó 
¡¡ 
 3.session¶ÔÏó 
session¶ÔÏóÖ¸µÄÊÇ¿Í»§¶ËÓë·þÎñÆ÷µÄÒ»´Î»á»°£


Ïà¹ØÎĵµ£º

jspѧϰ±Ê¼Ç1

JSP£¨java server page£©
JSPÊÇ·þÎñÆ÷¶ËÔËÐеÄÒ³Ã棬JSP±¾Ê¾ÍÊÇÒ»¸öÎĵµ£¬Ëû²»½ö¿ÉÒÔ°üº¬¾²Ì¬µÄHTML´úÂ룬Ҳ¿ÉÒÔ°üº¬¶¯Ì¬µÄJAVA´úÂ룬·þÎñÆ÷ÈÝÆ÷¿ÉÒÔ½«JSPת»»³ÉServlet·¢²¼£¬²¢½ÓÊÜÇëÇó¡£
JspÎļþÖ»Ðè·ÅÔÚÓ¦ÓÃÎļþϾͿÉÒÔÁË¡£
JSPÀý×Ó£º
     <html>
     <head& ......

jspѧϰ±Ê¼Ç3

×¢Ò⣺jsp:useBean¶¯×÷£¬ÓÃ±íµ¥ÎªBeanµÄÊôÐÔ¸³ÖµÊ±£¬Ò²¾ÍÊÇjsp:setProperty¶¯×÷Ö±½ÓÊÕÇëÇóÖÐ±íµ¥µÄÐÅϢΪʹÓõÄBeanµÄÊôÐÔ½øÐи³Öµ£¬Ò²¾ÍÊÇ˵jsp:useBeanºÍjsp:setProperty²»Äܹ»³öÏÖÔÚΪÕâ¸öBeanµÄÊôÐÔ¸³ÖµµÄform±íµ¥µÄÒ³ÃæÉÏ¡£
JSPµÄÒì³£´¦Àí
<%@page errorPage="xxx.jsp"%> Ö¸¶¨±¾Ò³Ãæ³öÏÖÒì³£ºóҪתµ½µÄÒ³Ãæ
& ......

jspѧϰ±Ê¼Ç5

JSP2.0Öеıí´ïʽÓïÑÔ(EL±í´ïʽ)
ELÓï·¨
ELµÄÓï·¨ºÜ¼òµ¥£¬Ëû×î´óµÄÌصã¾ÍÊÇʹÓÃÉϺܷ½±ã
Àý£º
${sessionScope.user.sex}
ËùÓÐEL¶¼ÊÇÒÔ ${ ΪÆðʼ¡¢ÒÔ} Ϊ½áβµÄ¡£
ÉÏÊöEL·¶ÀýµÄÒâ˼ÊÇ£º´ÓSessionÈ¡µÃÓû§µÄÐÔ±ð¡£Èç¹ûʹÓÃ֮ǰJSP´úÂëµÄд·¨ÈçÏ£º
<%
  User user = (User)session.getAttribute("user");
& ......

JspµÄ¾ÅÖÖ¶ÔÏó

JspµÄ¾ÅÖÖ¶ÔÏóÎÒ¼òÊöÖ®£º
page
application
request
response
session
config
out
pageContext
 
page
<%@page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" %>
response
<%
  response.setHeader("Pragma","No-cache"); 
  respons ......

jspÁ¬½Ómysql¶ÔÊý¾Ý¿â½øÐвÙ×÷ÂÒÂëµÄ½â¾ö


Èç¹ûjsp²åÈëmysqlÊý¾Ý¿â³öÏÖÂÒÂ룬mysqlÊý¾Ý¿â°²×°Ê±±àÂëÉèΪutf8£¬ÔÚÖ´ÐвåÈëÓï¾äµÄÇ°Ã棨½ô°¤×ÅÖ´ÐÐÓï¾ä£©Ìí¼ÓתÂëÓï¾ä£ºString na="";
                  try{
          &nbs ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ