JSP¾Å¸öÄÚÖöÔÏó
ѧϰJ2EE£¬±ØÐë¶ÔÏÂÃæµÄ¼¸¸ö¶ÔÏóÓкÜÉîµÄÀí½â
1¡¢request -> javax.servlet.http.HttpServletRequestµÄʵÀý
¸Ã¶ÔÏó·â×°ÁËÒ»´ÎÇëÇ󣬿ͻ§¶ËµÄÇëÇó²ÎÊý¶¼±»·â×°ÔڸöÔÏóÀï¡£ÕâÊÇÒ»¸ö³£ÓõĶÔÏ󣬻ñÈ¡¿Í»§¶ËÇëÇó²ÎÊý±ØÐëʹÓøöÔÏó¡£³£Óõķ½·¨ÓÐgetParameter(String paramName)¡¢getParameterValues(String paramName)¡¢setAttribute(String atttName,Object attrValue)¡¢getAttribute(String attrName)ºÍsetCharacterEncoding(String env)µÈ¡£
2¡¢response -> javax.servlet.http.HttpServletResponseµÄʵÀý
´ú±í·þÎñÆ÷¶Ô¿Í»§¶ËµÄÏìÓ¦¡£Í¨³£ºÜÉÙʹÓøöÔÏóÖ±½ÓÏìÓ¦£¬¶øÊÇʹÓÃout¶ÔÏ󣬳ý·ÇÐèÒªÉú³É·Ç×Ö·ûÏìÓ¦¡£¶øresponse¶ÔÏó³£ÓÃÓÚÖض¨Ïò£¬³£Óõķ½·¨ÓÐgetOutputStream()¡¢sendRedirect(java.lang.String location)µÈ¡£
3¡¢session -> javax.servlet.http.HttpSessionµÄʵÀý
¸Ã¶ÔÏó´ú±íÒ»´Î»á»°¡£µ±¿Í»§¶Ëä¯ÀÀÆ÷ÓëÕ¾µã½¨Á¢Á¬½Óʱ£¬»á»°¿ªÊ¼£»µ±¿Í»§¶Ë¹Ø±Õä¯ÀÀÆ÷ʱ£¬»á»°½áÊø¡£³£Óõķ½·¨ÓУºgetAttribute(String attrName)¡¢setAttribute(String attrName, Object attrValue)µÈ¡£ÔÚÓû§µÇ¼´¦ÀíµÄʱºò¾³£Ê¹ÓÃÕâ¸ö¶ÔÏó¡£
4¡¢pageContext -> javax.servlet.jsp.PageContextµÄʵÀý
¸Ã¶ÔÏó´ú±í¸ÃJSPÒ³ÃæÉÏÏÂÎÄ£¬Ê¹ÓøöÔÏó¿ÉÒÔ·ÃÎÊÒ³ÃæÖеĹ²ÏíÊý¾Ý¡£³£Óõķ½·¨ÓÐgetServletContext()ºÍgetServletConfig()µÈ¡£¾³£ÔÚJspÖж¨ÒåһЩÊôÐÔ¾ÍÊDZ»·Å½øÕâ¸öʵÀýÖС£
5¡¢application -> javax.servlet.ServletContextµÄʵÀý
¸ÃʵÀý´ú±íJSPËùÊôµÄWebÓ¦Óñ¾Éí£¬¿ÉÓÃÓÚJSPÒ³Ã棬»òÕßServletÖ®¼ä½»»»ÐÅÏ¢¡£³£Óõķ½·¨ÓÐgetAttribute(String attName)¡¢setAttribute(String attName , String attValue)ºÍgetInitParameter(String paramName)µÈ¡£
6¡¢config -> javax.servlet.ServletConfigµÄʵÀý
¸ÃʵÀý´ú±í¸ÃJSPµÄÅäÖÃÐÅÏ¢¡£³£Óõķ½·¨ÓÐgetInitParameter(String paramName)ºÍgetInitParameternames()µÈ·½·¨¡£ÊÂʵÉÏ£¬JSPÒ³Ãæͨ³£ÎÞÐëÅäÖã¬Ò²¾Í²»´æÔÚÅäÖÃÐÅÏ¢¡£Òò´Ë£¬¸Ã¶ÔÏ
Ïà¹ØÎĵµ£º
Ô´³ÌÐò
<%String sConn="ÄãµÄÁ¬½Ó"
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection(sConn,"ÄãµÄÓû§Ãû","ÃÜÂë");
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
Statement stmtcount=conn.createStat ......
1 web·þÎñÆ÷{TOMCAT(JSP)¡¢WEBLOGIC(JSP) }
Ó¦Ó÷þÎñÆ÷
We ......
Àý×Ó˵Ã÷£ºÕâÀý×ÓÊÇѧÉú»ù±¾ÐÅÏ¢µÄÊäÈëÒÔ¼°Êä³öÏÔʾ;ÓÐÁ½¸öÒ³Ã棺info.jspºÍshowInfo.jsp£¬Ç°ÕßÊǹ˿ÍÊäÈëµÄÐÅÏ¢Ò³Ã棬¶øºóÕßÊÇ´¦ÀíÐÅÏ¢µÄÒ³Ãæ¡£
info.jsp
<%@page contentType="text/html;charset=gb2312"%>
<HTML>
<HEAD>
<TITLE>ÊäÈëѧ ......
jspÂÒÂëÎÊÌ⣬ÇóÖú
ÏÂÁ˸ö¼¸ÄêÇ°µÄjspÔ´Â룬ÎÒ×°ÉϺóÒ»Ö±ÓÐÖÐÎÄÂÒÂëÎÊÌ⣬Êý¾Ý¿âÎÒÓÃmysql£¬
²¢ÓÃsql-front²Ù×÷£¬ÔÚÓÃsql-frontµÄʱºòÒÑ°Ñ×Ö·ûÉèÖÃΪgb2312£¬
¶øÇÒÔÚsql-frontÖÐÄÜÕýÈ·ÏÔʾÖÐÎÄ£¬µ«¾ÍÊÇÔÚjspÒ³ÃæÉÏÓÃgetstring·½·¨
µÃµ½ÂÒÂ룬ÎÒÒ²Óùýgetbytes£¨iso-8859-1£©µÈ·½·¨ÊÔ¹ý»¹ÊÇûÓÐ ......
ÎÒÏÖÔÚ¸øÄãÒ»¸öJAVAºÍJSPÖ®¼äµÄ¹Øϵ,ÒÔ¼°JAVAµÄÍêÕûÈÏʶ
JAVA·ÖΪJ2EE,J2SE.J2ME,ÏÂÃæ·Ö±ð½éÉÜ:
Ò».J2EE£ºJava 2 Platform Enterprise Edition ÆóÒµ°æ£¬ÓÃÓÚÆóÒµÓ¦Óã¬Ö§³Ö·Ö²¼Ê½²¿Êð¡£
J2EEƽ̨ÓÉÒ»ÕûÌ×·þÎñ£¨Services£©¡¢Ó¦ÓóÌÐò½Ó¿Ú£¨APIs£©ºÍÐÒé¹¹³É£¬
Ëü¶Ô¿ª·¢»ùÓÚWebµÄ¶à²ãÓ¦ÓÃÌṩÁ˹¦ÄÜÉϵÄÖ§³Ö¡£Ëü°ü ......