1. What isServlet?
Background:
In the Client/Server solution, the program can be automatically downloaded to the client and executed. In the past, more people focused on developing the applet and graphical user interface (GUI) components on the client. Applet is indeed an important part of the client/server computing environment, but it is only half of the problem. Now, we need to have an in-depth understanding of the other side of the problem-servlet.
Concept:
Servlet is a server applet written in Java. It can be considered as a server-side applet. The servlet is loaded and executed by the Web server, just as the applet is loaded and executed by the browser. The servlet receives a request from the client (through a web server), executes a job, and then returns the result (may be displayed on the browser's JSP page ).
II,Servlet framework composition (servletapi)
The servlet framework consists of two Java packages: javax. servlet and javax. servlet. HTTP. In our programming, We need to import data at the beginning,
Javax. servlet .*;
Core of the servlet framework: javax. servlet. servlet interface, which must be implemented by all servlets.
The javax. servlet class contains all the interfaces and classes to be implemented. javax. servlet. Http contains all the classes using the HTTP Communication Protocol.
Note: The introduction and usage of specific classes are as follows.
Iii. Development Tools
JDK: jdk1.6.0 _ 10
Server: C:/tomcat 5.0 (strictly speaking, it should be a Web Container)
Compilation tool: jcreator pro 3.5038513 Chinese version (I used this tool. It supports Chinese display and is downloaded from csdn .)
Tomcat settings:
1) create a folder: C:/tomcat 5.0/webapps/myservlet/WEB-INF/classes
2) C:/tomcat 5.0/webapps/myservlet/Add web under the WEB-INF. XML file, you can directly copy C:/tomcat 5.0/webapps/root/WEB-INF under the web. paste the XML file.
3) [import ORACLE data connection component] copy and paste D:/Oracle/ora90/jdbc/lib/classes12.jar to C:/tomcat 5.0/common/lib.
NOTE: If MSSQL is used, you need to copy three components.
Jcreator settings:
1. Introduce the servlet package
Click "add" -- "add Archive" (second), select C:/tomcat 5.0/common/lib/servlet-api.jar, and then apply -- OK.
2. Similarly, classes12.jar is introduced.
In this way, the servlet + JSP programming environment has been set up. Let's start the servlet + JSP programming journey.