JSP 9´ó¶ÔÏóÏê½â
ѧϰJSPÖ÷ҪѧϰËûµÄ9´ó¶ÔÏó(request, response, pageContext, session, application, out, config, page, exception ),ÕâЩ¶ÔÏó¶¼ÊǾ²Ì¬¶ÔÏ󣬲»Óö¨Òå¾Í¿ÉÒÔÖ±½ÓʹÓ㬰ÑËûÃǶ¼Á˽âÇå³þ²¢»áÔËÓ㬾ͿÉÒÔÔÚ¼òÀúÉÏÌíÉÏÒ»¸öÊìϤ¼¼ÄÜ:JSP
JspÄÚÖöÔÏó ¹¦ÄÜ Ö÷Òª·½·¨
out Ïò¿Í»§¶ËÊä³öÊý¾Ý print() println() flush() clear() isAutoFlush() getBufferSize() close() …………
request Ïò¿Í»§¶ËÇëÇóÊý¾Ý
ͨ¹ýËüÈ¡µÃÀ´×Ô¿Í»§¶ËµÄparameters,cookies,headerµÈÐÅÏ¢ getAttributeNames() getCookies() getParameter() getParameterValues() setAttribute() getServletPath() …………..
response ·â×°ÁËjsp²úÉúµÄÏìÓ¦£¬È»ºó±»·¢Ë͵½¿Í»§¶ËÒÔÏìÓ¦¿Í»§µÄÇëÇó addCookie() sendRedirect() setContentType()
flushBuffer() getBufferSize() getOutputStream()
sendError() containsHeader()……………
application Ó¦ÓóÌÐò¼¶¶ÔÏ󣨼´Ó¦ÓóÌÐòÉÏÏÂÎÄ£©,¶à¸öÓû§Ö®¼ä¹²ÏíÐÅÏ¢
config ±íʾServletµÄÅäÖ㬵±Ò»¸öServlet³õʼ»¯Ê±£¬ÈÝÆ÷°ÑijЩÐÅϢͨ¹ý´Ë¶ÔÏ󴫵ݸøÕâ¸öServlet
JSPµÄÅäÖÃÐÅÏ¢£¬×÷ÓÃÓòΪҳÃæ getServletContext() getServletName() getInitParameter() getInitParameterNames()……………
page ¶ÔÓ¦this¹Ø¼ü×Ö¡£JSPÍøÒ³±¾Éí£¬JspʵÏÖÀàµÄʵÀý£¬ËüÊÇjsp±¾Éí£¬Í¨¹ýÕâ¸ö¿ÉÒÔ¶ÔËü½øÐзÃÎÊ flush()………
pagecontext ΪJSPÒ³Ãæ°ü×°Ò³ÃæµÄÉÏÏÂÎÄ¡£¹ÜÀí¶ÔÊôÓÚJSPÖÐÌØÊâ¿É¼û²¿·ÖÖмº¾ÃüÃû¶ÔÏóµÄ¸ÃÎÊ ÍøÒ³µÄÊôÐÔÊÇÔÚÕâÀï¹ÜÀí forward() getAttribute() getException() getRequest() getResponse() getServletConfig()
getSession() getServletContext() setAttribute()
removeAttribute() findAttribute() ……………
session Óû§¼¶¶ÔÏó£¬ÓÃÀ´±£´æÿ¸öÓû§µÄÐÅÏ¢£¬ÒÔ±ã¸ú×Ùÿ¸öÓû§µÄ²Ù×÷״̬ͨ¹ý <%@ page session ="false" %>¸ÃÒ³Ãæ½ûÖ¹»á»° getAttribute() getId() getAttributeNames() getCreateTime() getMaxInactiveInterval()
invalidate() isNew()
exception ·´Ó³ÔËÐеÄÒì³£Ö»ÓÐÔÚpageÖ¸ÁîÖÐÖ¸¶¨isErrorPage = "true"ÊôÐÔ£¬²Å¿ÉÒÔʹÓÃÕâ¸ö¶ÔÏó¡£ getMessage()…&h
Ïà¹ØÎĵµ£º
image.jspÓÃÓÚÉú³ÉÊý×ÖͼƬ
<%@ page contentType="image/jpeg;charset=gb2312" import="java.awt.*,
java.awt.image.*,java.util.*,javax.imageio.*" %>
<%!
Color getRandColor(int fc,int bc){//¸ø¶¨·¶Î§»ñµÃËæ»úÑÕÉ«
Random random = new Rand ......
½¨Á¢Ìõ¼þÊ×ÏÈÒ»¶¨ÒªÈ·¶¨×Ô¼ºµÄmysql£¬tomcat,eclipseÁ¬½ÓÊÇÕýÈ·µÄ¡£
index.jspºÜ¼òµ¥£¬¾ÍÒ»¸öÌøת¡£
<%
response.sendRedirect("lg.jsp");
%>
lg.jsp ʵÏֵǼ¿ò¼Ü
<%@ page contentType="text/html; charset=utf-8" %>
<html>
<head>
<title>
login
</title>
</hea ......
£±.×îÖ±½Ó×î¼òµ¥µÄ£¬·½Ê½ÊÇ°ÑÎļþµØÖ·Ö±½Ó·Åµ½htmlÒ³ÃæµÄÒ»¸öÁ´½ÓÖС£ÕâÑù×öµÄȱµãÊÇ°ÑÎļþÔÚ·þÎñÆ÷ÉϵÄ·¾¶±©Â¶ÁË£¬²¢ÇÒ»¹ÎÞ·¨¶ÔÎļþÏÂÔؽøÐÐÆäËüµÄ¿ØÖÆ£¨ÈçȨÏÞ£©¡£Õâ¸ö¾Í²»Ð´Ê¾ÀýÁË¡£
£².ÔÚ·þÎñÆ÷¶Ë°ÑÎļþת»»³ÉÊä³öÁ÷£¬Ð´Èëµ½response£¬ÒÔresponse°ÑÎļþ´øµ½ä¯ÀÀÆ÷£¬ÓÉä¯ÀÀÆ÷À´ÌáʾÓû§ÊÇ·ñÔ¸Òâ±£´æÎ ......
<%--
ÓÐЩÅóÓÑѯÎÊʹÓà JSP Smart ÏÂÔØÎļþµÄʱºò±¨´í, ÕâÀï¸ø³öÒ»¸ö²âÊÔ¹ýµÄ²»
ÐèҪʹÓà JSP Smart µÄ JSP Ò³ÃæÖнøÐÐÎļþÏÂÔصĴúÂë(¸Ä Servlet »òÕß
JavaBean µÄ»°×Ô¼º¸Ä°É), Ö§³ÖÖÐÎĸ½¼þÃû(×öÁËתÄÚÂë´¦Àí). ÊÂʵÉÏÖ»ÒªÏò ......