is a server-side program written in Java. Its main function is to interactively browse and modify data to generate dynamic Web content.
First, create a Web project
1) Process: Eclipse-file-new-other-web-denamic Web Project-next (refer to drawings)
2) Enter the project name, Target Runtime, configuration, and click Next when you are finished. If you do not have an integrated tomcat, configure it first.
3) This page does not need to modify and fill in the content, directly click Next, go to the next page
4) Check the selection in the drawings, click Finish, complete the creation
Second, modify the view and create the servlet
1) For example, the Web project is displayed as follows:
2) Click Windows-show view-other-java-package Explorer in the navigation bar, click the 0k button
3) View the project directory at this time as follows:
4) Create a package under the SRC file
Process: Right-click src-new-other-java-package-next-to fill in the Package name-click the Finish button, as
5) Create servlet
Process: Select New Package Right click-new-servlet-Fill in Class Name-next-next-finish (where Doget () and Dopost () method are checked)
Open a new servlet
Add the code in the Doget () and Dopost () methods, import the Printwrite package,
Configure Tomcat, click servlet-Double-click tomcat-Select modules-click Add Web modoules-Double-click the new servlet, click the OK button
Running a servlet
Right-click Tomcat-debug
Enter in the browser: Http://localhost:8080/JAVAWeb_Servlet_Study_001/ServletDemo_001,enter run
Note:
LocalHost is the domain name, which is your server address, now you are running on this machine, localhost is the representative of your local machine, you can also use 127.0.0.1 instead
Or you can open the command operator interface (remember that this does not, as the view JDK version open that interface, and then enter Ipconfig return to see their own IP address), with this IP address replacement is also possible.
8080 is the port number of the Tomcat service (each service on the Windows operating system will have a corresponding port number)
JAVAWEB_SERVLET_STUDY_001 is the context.
ServletDemo1 is the name of the annotation above the class you created.
Also, modifying these configurations requires a reboot to take effect
The first step to opening a new World: learning the servlet