TomcatÏÂjsp,sevlet,javabeanÅäÖÆ
¾³£¿´µ½jspµÄ³õѧÕßÎÊtomcatÏÂÈçºÎÅäÖÃjsp¡¢servletºÍbeanµÄÎÊÌ⣬ÓÚÊÇ×ܽáÁËÒ»ÏÂÈçºÎtomcatÏÂÅäÖÃjsp¡¢servletºÍben£¬Ï£Íû¶ÔÄÇЩ³õѧÕßÓÐËù°ïÖú¡£
µÚÒ»²½£ºÏÂÔØj2sdkºÍtomcat£ºµ½sun¹Ù·½Õ¾µã£¨http://java.sun.com/j2se/1.4.2/download.html£©ÏÂÔØj2sdk£¬×¢ÒâÏÂÔذ汾ΪWindows Offline InstallationµÄSDK£¬Í¬Ê±×îºÃÏÂÔØJ2SE 1.4.2 Documentation£¬È»ºóµ½tomcat¹Ù·½Õ¾µã£¨http://www.apache.org/dist/jakarta/tomcat-4/£©ÏÂÔØtomcat£¨ÏÂÔØ×îÐÂ4.1.x°æ±¾µÄtomcat£©£»
µÚ¶þ²½£º°²×°ºÍÅäÖÃÄãµÄj2sdkºÍtomcat£ºÖ´ÐÐj2sdkºÍtomcatµÄ°²×°³ÌÐò£¬È»ºó°´Ä¬ÈÏÉèÖýøÐа²×°¼´¿É¡£
1.°²×°j2sdkÒÔºó£¬ÐèÒªÅäÖÃһϻ·¾³±äÁ¿£¬ÔÚÎҵĵçÄÔ->ÊôÐÔ->¸ß¼¶->»·¾³±äÁ¿->ϵͳ±äÁ¿ÖÐÌí¼ÓÒÔÏ»·¾³±äÁ¿(¼Ù¶¨ÄãµÄj2sdk°²×°ÔÚc:\j2sdk1.4.2£©£º
JAVA_HOME=c:\j2sdk1.4.2
classpath=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;£¨.;Ò»¶¨²»ÄÜÉÙ£¬ÒòΪËü´ú±íµ±Ç°Â·¾¶)
path=%JAVA_HOME%\bin
½Ó×Å¿ÉÒÔдһ¸ö¼òµ¥µÄjava³ÌÐòÀ´²âÊÔJ2SDKÊÇ·ñÒÑ°²×°³É¹¦£º
public class Test{
public static void main(String args[]){
System.out.println("This is a test program.");
}
}
½«ÉÏÃæµÄÕâ¶Î³ÌÐò±£´æΪÎļþÃûΪTest.javaµÄÎļþ¡£
È»ºó´ò¿ªÃüÁîÌáʾ·û´°¿Ú£¬cdµ½ÄãµÄTest.javaËùÔÚĿ¼£¬È»ºó¼üÈëÏÂÃæµÄÃüÁî
javac Test.java
java Test
´ËʱÈç¹û¿´µ½´òÓ¡³öÀ´This is a test program.µÄ»°ËµÃ÷°²×°³É¹¦ÁË£¬Èç¹ûûÓдòÓ¡³öÕâ¾ä»°£¬ÄãÐèÒª×Ðϸ¼ì²éÒ»ÏÂÄãµÄÅäÖÃÇé¿ö¡£
2.°²×°Tomcatºó£¬ÔÚÎҵĵçÄÔ->ÊôÐÔ->¸ß¼¶->»·¾³±äÁ¿->ϵͳ±äÁ¿ÖÐÌí¼ÓÒÔÏ»·¾³±äÁ¿(¼Ù¶¨ÄãµÄtomcat°²×°ÔÚc:\tomcat£©£º
CATALINA_HOME=c:\tomcat;
CATALINA_BASE=c:\tomcat;
È»ºóÐ޸Ļ·¾³±äÁ¿ÖеÄclasspath£¬°Ñtomat°²×°Ä¿Â¼ÏµÄcommon\libϵÄservlet.jar×·¼Óµ½classpathÖÐÈ¥£¬Ð޸ĺóµÄclasspathÈçÏ£º
classpath=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\common\lib\servlet.jar;
½Ó×Å¿ÉÒÔÆô¶¯tomcat£¬ÔÚIEÖзÃÎÊhttp://localhost:8080£¬Èç¹û¿´µ½tomcatµÄ»¶ÓÒ³ÃæµÄ»°ËµÃ÷°²×°³É¹¦ÁË¡£
µÚÈý²½£º½¨Á¢×Ô¼ºµÄjsp appĿ¼
1.µ½TomcatµÄ°²×°Ä¿Â¼µÄwebappsĿ¼£¬¿ÉÒÔ¿´µ½ROOT£¬examples, tomcat-docsÖ®ÀàTomcat×Ô´øµÄµÄĿ¼£»
2.ÔÚwebappsĿ¼ÏÂн¨Ò»¸öĿ¼£¬ÆðÃû½Ðmyapp£»
3.myappÏÂн¨Ò»¸öĿ¼WEB-INF£¬×¢Ò
Ïà¹ØÎĵµ£º
JavaBeanÊÇSun¹«Ë¾ÃæÏò»ùÓÚ×é¼þµÄ¿ª·¢¶øÖƶ¨µÄÒ»Ì׹淶£¬µ«ÔÚʵ¼ÊµÄJ2EE¿ª·¢ÖУ¬Í¨³£Ö»Ðè·ûºÏÈçÏÂÌص㣺
(1)Õâ¸öJavaÀà±ØÐë¾ßÓÐÒ»¸öÎ޲εĹ¹Ô캯Êý£»
(2)ÊôÐÔ±ØÐë˽Óл¯£»
(3)˽Óл¯µÄÊôÐÔ±ØÐëͨ¹ýpublicÀàÐ͵ķ½·¨±©Â¶¸øÆäËü³ÌÐò£¬²¢ÇÒ·½·¨µÄÃüÃûÒ²±ØÐë×ñÊØÒ»¶¨µÄÃüÃû¹æ·¶¡£
JavaBeanÔÚJ2EE¿ª·¢ÖУ¬Í¨³£ÓÃÓÚ·â×°Êý¾Ý ......
jsp(java server pages)ÊÇÒ»ÖÖ¼¼Êõ,ÓÃÀ´´¦Àí¿Í»§¶ËÇëÇóµÄ,(Ä¿µÄÊÇΪÁË´ïµ½¶¯Ì¬ÍøÒ³µÄЧ¹û),´¦Àíºó´«¸ø¿Í»§¶Ë(Ò²¿ÉÒÔ˵¸øÁËä¯ÀÀÆ÷),¾Í³ÉÁËÎÒÃÇ¿´µ½µÄ¾²Ì¬ÍøÒ³(HTML)
HTML ¼ÓÈëJava´úÂë(±ÈÈç<%...%>)²»»áÓÖÈκÎЧ¹û,Ö»»á½²<%...%>ÏÔʾµ½Ò³ÃæÐÐ,»òÕ߸ù¾ÝλÖÃÓ°Ïì±àÒë. JSP(Java Server Page)Ò³ÃæÆäʵ¾ÍÊÇ ......
AjaxºÍjspµÄ¹ÖÏÖÏó
Èç¹ûÓÃAjaxÈ¥ÇëÇóÒ»¸öjspÒ³Ã棬¸ÃjspÒ³Ãæ·µ»ØµÄÊÇxml£¨response.setContentType("text/xml; charset=GB2312");£©£¬²¢ÇÒ¸Ãjsp°üº¬ÏÂÃæÕâЩͷ@pageÖ¸ÁîµÄ»°£¬ÔòÔÚ¿Í»§¶Ëxml=XMLHttpRequest.responseXMLµÃµ½µÄÊÇÒ»¸ö²»°üº¬ÈÎÎñ¶«Î÷µÄxml¶ÔÏ󣬼´xml.childNodes.length½«»áÊÇ0.
......
Login.java
/******************************************************/
×¢Ò⣺ÓÉÓÚÔÚjspÖд´½¨Cookieʱ£¬±ØÐë±£Ö¤Cookie´´½¨Óï¾äдÔÚjspÒ³ÃæÍ·²¿µÄ<jsp:include page="includes\head.jsp" flush="true" />±êǩ֮ǰ²Å»áÉúЧ£¬·ñÔòÊÖ¶¯Ìí¼ÓµÄCookieʧ°Ü¡£
ËùÒÔÎÒ¾ö¶¨½²´´½¨CookieÓï¾ä·ÅÔÚservl ......
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="config/config_SelfHelp.jsp"%>
<%@ include file="sh_Bookmark_Data.jsp"%>
<html xmlns:v>
<head>
<title>ÎÒµÄÊéÇ©</title>
<style type="text/css">
tabl ......