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

Tomcat 6 + JDK1.6u2 ÅäÖÃjsp, servlet, beanʵ¼ù


Ò»¡¢ÎļþÏÂÔؼ°°æ±¾
apache-tomcat-6.0.20.exe
jdk-6u2-windows-i586-p.exe
¶þ¡¢°²×°¼°»·¾³±äÁ¿ÉèÖÃ
Èí¼þ°²×°ºó£¬ÐèÒªÅäÖû·¾³±äÁ¿¡£Ð½¨JAVA_HOME, CATALINA_HOME, classpath,ÐÞ¸Äpath£º
classpath = ".;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\lib\servlet-api.jar"
path += ";%JAVA_HOME%\bin"
Ϊ±£ÕÏservlet Java³ÌÐòµÄ±àÒëͨ¹ý£¬»¹Òª½«%TOMCAT_HOME%\libĿ¼ÏµÄservlet-api.jar¸´ÖƵ½%JAVA_HOME%\jre\lib\extĿ¼Ï£¬ÒòΪjavax.servlet.*Ïà¹Ø´úÂëÐèÒª¸Ãjar°ü¡£
Èý¡¢´´½¨ÐÂÓ¦Óü°Ïà¹Ø´úÂë
ÔÚ%TOMCAT_HOME%\webapps\Ŀ¼Ï£¬´´½¨myappĿ¼£¬×÷Ϊ×Ô¼ºµÄÐÂÓ¦ÓÃĿ¼¡£ÒÀ´Î´´½¨ÈçÏÂĿ¼½á¹¹£ºmyapp\WEB-INF\classes\test\
ÔÚmyappĿ¼Ï£¬´´½¨index.jspºÍtestBean.jsp£»ÔÚWEB-INFĿ¼Ï£¬´´½¨web.xml£»ÔÚtestĿ¼Ï£¬´´½¨TestServlet.javaºÍTestBean.java
Ïà¹Ø´úÂë·Ö±ðÈçÏ£º
index.jsp, ²âÊÔjspÅäÖÃÓá£
-------------
<html>
<body>
This is a test index
</body>
</html>
-------------
testBean.jsp, ²âÊÔJava BeanÅäÖÃÓÃ
-------------
<%@ page import="test.TestBean" %>
<html>
<body>
<center>
<%
TestBean testBean=new TestBean("This is a test java bean.");
%>
Java bean name is: <%=testBean.getName()%>
</center>
</body>
</html>
-------------
TestBean.java, ²âÊÔJavaBeanÅäÖÃÓÃ
-------------
package test;
public class TestBean{
private String name = null;
public TestBean(String strName){
   this.name = strName;
}
public void setName(String strName){
   this.name = strName;
}
public String getName(){
   return this.name;
}
}
-------------
TestServlet.java, ²âÊÔServletÅäÖÃÓÃ
-------------
package test;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class TestServlet extends HttpServlet{
protected void doGet(HttpServletRequest request, HttpServletResponse response)


Ïà¹ØÎĵµ£º

jsp Ò³Ãæ³öÏÖÂÒÂë

´Ó html Ò³Ã渴ÖƵ½ jsp Ò³Ãæ³öÏÖÂÒÂ룺
   
       ½« html µÄ <?xml version="1.0" encoding="UTF-8"?> ¸ÄΪ jsp µÄ
    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> ¼´¿É½â¾öÎÊÌâ¡£
   ......

MysqlͨÓòéѯ²Ù×÷Àà(Jsp+servlet+javaBean+Mysql)

ÔÚÌÚ¿ÆÅàѵÁËÓÐ1¸ö°ëÔÂÁË£¬ÖÕÓÚѧÍêJSP+SERVLET+JAVABEAN+MYSQL£¬Ñ§ÁËjavaµÄµÚÒ»Ì×web½â¾ö·½°¸¡£ÀÏʦҪÇóÎÒÃÇ6ÈËÒ»×鿪ʼ×öÒ»¸ö¶©²Íϵͳ¡£Õâ¸öϵͳûÓÐʲôÌرðµÄ£¬¾Í¸úµç×ÓÉ̳ÇÊÇÒ»¸öÑùµÄ¡£ÓÉÓÚÒª¶ÔÊý¾Ý¿â×ö´óÁ¿µÄÔöɾ¸Ä²é£¬ÄǸö´úÂëÓֶ࣬ÎÒÏëÄܲ»Äܽ«Êý¾Ý¿â²Ù×÷µÄÕâÒ»²ã´ò°üÆðÀ´(SqlOperDao)£¬ÈÃÎÒ¶ÔÊý¾Ý¿â²Ù×÷£¬Óü¸Ðд ......

Jsp ÑéÖ¤Âë(¼ìÑéÂë)µÄʵÏÖ


ÀûÓÃApacheµÄÒ»¸ö ¿ªÔ´ÏîÄ¿Image Tag Library(http://jakarta.apache.org/taglibs/sandbox/doc/image-doc/intro.html)
ÀûÓÃApacheµÄÒ»¸ö ¿ªÔ´ÏîÄ¿Image Tag Library(http://jakarta.apache.org/taglibs/sandbox/doc/image-doc/intro.html)
ÏÂÔرØÒªÎļþ
1)ÏÂÔØJakarta-Taglibs:
http://people.apache.org/builds/jaka ......

jspµÄsessionÏê½â


http://www.egzcn.com/article/webbc/JSP/2006-03-22/2003.html À´Ô´
ÕªÒª£ºËäÈ»session»úÖÆÔÚwebÓ¦ÓóÌÐòÖб»²ÉÓÃÒѾ­ºÜ³¤Ê±¼äÁË£¬µ«ÊÇÈÔÈ»ÓкܶàÈ˲»Çå³þsession»úÖƵı¾ÖÊ£¬ÒÔÖÁ²»ÄÜÕýÈ·µÄÓ¦ÓÃÕâÒ»¼¼Êõ¡£±¾ÎĽ«ÏêϸÌÖÂÛsessionµÄ¹¤×÷»úÖƲ¢ÇÒ¶ÔÔÚJava web applicationÖÐÓ¦ÓÃsession»úÖÆʱ³£¼ûµÄÎÊÌâ×÷ ......

jsp ¹ýÂËÆ÷ºÍ¼àÌýÆ÷

ת×Ô£ºhttp://www.blogjava.net/beansoft/archive/2007/11/09/159374.html
¼ÙÉèÓÐÒ»¸ö·Ç³£Î£ÏÕµÄÈÎÎñ, ÊǾÅËÀÒ»Éú. ÐèÒªÄã´§×ÅÕ¨Ò©°ü´Ó±±Æ½¿ª³µ×߸ßËÙ·¹ý±£¶¨È¥Ê¯¼Òׯ°Ñ¹í×ӵĵﱤ¸øÕ¨ÁË. ×¢Òâ: Õâ¸öÈÎÎñÊ®·Ö¼è¾Þ, ÓпÉÄÜ°ë·ըҩ±¬Õ¨. ËùÒÔ³ö·¢Ç°ÄãÐèÒª¿àÁ·10ÔªÒ»±¾µÄ<<Ìú²¼ÉÀ>>, »¹ÐèÒªÁ¢ÒÅÖö½»´úһϺóÊÂ. ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ