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¶ÔÏóÖ¸µÄÊÇ¿Í»§¶ËÓë·þÎñÆ÷µÄÒ»´Î»á»°£¬´Ó¿Í»§Á¬µ½·þÎñÆ÷µÄÒ»¸öWebApplication¿ªÊ¼£¬Ö±µ½¿Í»§¶ËÓë·þÎñÆ÷¶Ï¿ªÁ¬½ÓΪֹ¡£ËüÊÇHttpSessionÀàµÄʵÀý.
ÐòºÅ ·½ ·¨ ˵ Ã÷
1 long getCreationTime() ·µ»ØSESSION´´½¨Ê±¼ä
2 public String
Ïà¹ØÎĵµ£º
private String projectName="sz_pro"; // ÄãÏîÄ¿µÄÃû³Æ
//»ñÈ¡µ±Ç°ÏîÄ¿µÄ¾ø¶Ô·¾¶
public String getPorjectPath(){
String nowpath; //µ±Ç°tomcatµÄbi ......
×ܵÄÀ´½²£¬JavaSever PagesTM£¨JSP£©ºÍ ΢ÈíµÄActive Sever Pages£¨ASP£©ÔÚ¼¼Êõ·½ÃæÓÐÐí¶àÏàËÆÖ®´¦¡£Á½Õ߶¼ÊÇΪ»ùÓÚWEBÓ¦ÓÃʵÏÖ¶¯Ì¬½»»¥ÍøÒ³ÖÆ×÷ÌṩµÄ¼¼Êõ»·¾³Ö§³Ö¡£Í¬µÈ³Ì¶ÈÉÏÀ´½²£¬Á½Õ߶¼Äܹ»Îª³ÌÐò¿ª·¢ÈËÔ±ÌṩʵÏÖÓ¦ÓóÌÐòµÄ±àÖÆÓë×Ô´ø×é¼þÉè¼ÆÍøÒ³´ÓÂß¼ÉÏ·ÖÀëµÄ¼¼Êõ¡£¶øÇÒÁ½Õ߶¼Äܹ»Ìæ´úCGIʹÍøÕ¾½¨ÉèÓë·¢Õ¹±äµÄ½ÏΪ ......
˵Ã÷£º»ùÓÚEclipse 3.2 + Tomcat 4.0±àÒëÍê³É
1.Íê³ÉÄã×Ô¼ºµÄTag Class£¬javax.servlet.jspÖÐÌṩһ¸öTag½Ó¿ÚÀà
TagSupport ºÍ BodyTagSupportÁ½¸öÀ࣬Äã×Ô¼ºµÄTag Class±ØÐë
extendsÆäÖÐÒ»¸ö¡£±¾ÀýÖÐHrefTag Class extends TagSupportÀ࣬²¢
Íê³ÉÁËdoStratTag·½·¨µÄÖØд£¬Ö÷Òª´úÂëÈçÏ£º
public int doStartTag(){
J ......
JSP²ÊÉ«ÑéÖ¤Âë
Éú³ÉÓÐ4¸öËæ»úÊý×ÖºÍÔÓÂÒ±³¾°µÄͼƬ£¬Êý×ֺͱ³¾°ÑÕÉ«»á¸Ä±ä£¬·þÎñÆ÷¶ËˢУ¨ÓÃhistory.go(-1)Ò²»á±ä£©
ÔÐͲο¼ALIBABA http://china.alibaba.com/member/showimage
²úÉúÑéÖ¤ÂëͼƬµÄÎļþ-----image.jsp
<%@ page contentType="image/jpeg" import="java.awt.*,java.awt.image.*,java.util.*,java ......
²úÉú״̬ÏìÓ¦Âë
100¡«199£º±íʾ·þÎñ¶Ë³É¹¦½ÓÊÕÇëÇ󣬵«ÒªÇó¿Í»§¶Ë¼ÌÐøÌá½»ÏÂÒ»´ÎÇëÇó²ÅÄÜÍê³ÉÈ«²¿´¦Àí¹ý³Ì¡£
200¡«299£º±íʾ·þÎñ¶ËÒѾ³É¹¦½ÓÊÕÇëÇ󣬲¢Íê³ÉÁËÈ«²¿´¦Àí¹ý³Ì¡£
300¡«399£º±íʾ¿Í»§¶ËÇëÇóµÄ×ÊÔ´ÒѾÒƵ½Á˱ðµÄλÖ㬲¢Ïò¿Í»§¶ËÌṩһ¸öеĵØÖ·£¬Ò»°ãÕâ¸öеØÖ·ÓÉHTTPÏìÓ¦ÏûϢͷµÄLocation×Ö¶ÎÖ¸¶¨¡£
400¡ ......