Graphical use Eclipse3 Sysdeo Tomcat Plugin editing and debugging JSP (1)
Graphical use Eclipse3 Sysdeo Tomcat Plugin editing and debugging JSP (2) 5. Editing Servlet programs
On the basis of successful editing and debugging JSP, it is relatively simple to edit and debug the servlet program.
1. Stop the Tomcat server first. Right click on the "Web-INF / SRC" directory, create new -> class,
Fill in the package name: "javamxj.tomcat.servlet"
Fill in the class name: "servletsample"
Click to complete.
2. Modify servletsample.java as follows:
Servletsample.java
/ *
* Create date 2004-10-18
* Author javamxj (9cbs blog)
* /
Package javamxj.tomcat.servlet;
Import java.io. *;
Import javax.servlet.http. *;
Import javax.servlet. *;
Public class servletsample extends httpservlet {
PRIVATE STRING S;
Public void doget (httpservletRequest Req, httpservletResponse res)
Throws ServleTexception, IOException
{
PrintWriter out = res. maxwriter ();
String s = "Hello, JavaMxj Blog!";
Out.println (s);
Out.close ();
}
}
3. Create a web.xml file in the web-inflicity, save the file.
WEB-INF / Web.xml
Xml Version = "1.0" encoding = "ISO-8859-1"?>
XMLns: XSI = " http://www.w3.org/2001/xmlschema-instance " XSI: SchemAlocation = " http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd " Version = "2.4"> servlet> servlet-maping> web-app> 4. Start the Tomcat server, enter "http:// localhost: 8080 / tomcatsample / servletsample" in the browser window 6. Debug the servlet program 1. Add a breakpoint to the servletsample.java file, as shown in the figure: 2. Refresh the browser window and switch to the "debug" view of Eclipse, change as follows: 3. At this point, the browser window is as follows: 7. Discuss the mechanism 1. In the Tomcat Directory / Conf / Server.xml file, or there is a TomcatSample.xml file in Tomcat Directory / Catalina / LocalHost, which should be included in these two files: (Note that the above statement will be different due to the different directories of Eclipse.) 2. Enter: "http: // localhost: 8080 /", click on the "Tomcat Manager" link on the left, one window will pop up, let you enter the username and password, in the second largest "environment configuration" In the third section of the medium, you have added a user to the Tomcat management interface, enter this user's username and password, here is "admin", "javamxj". 3. After entering the correct username and password, you will enter the Tomcat management interface, you can see that TomcatSample is running. You can stop, overload, or uninstall it. 4. Uninstall the Context definition from Eclipse now Right-click Tomcatsample Directory -> Tomcat Project-> Remove Context Difinition, as shown below: 5. When you refresh the browser window of the Tomcat management interface, you will find that "/ tomcatsample" has disappeared. at the same time, " 6. To re-add "/ tomcatsample" to the Tomcat application, you need to right-click the TomcatSample directory-> Tomcat Project-> Update Context Difinition, then restart Tomcat. So much, mainly for the next article, "How to use the Lomboz plug-in compile JSP" to make a paving, but also to better understand the use of this plugin.