MyEclipse First Servlet program--solving MyEclipse and Tomcat connection problem in Win7 system preface This article is intended to help the people who learn Java Web development, to be familiar with the environment, to run their first servlet program under the Win7 system, Because sometimes improper configuration or system causes may not run successfully, this gives beginners a certain annoyance, I also worry about for a few hours. The hands-on introduction uses MyEclipse, connects the Tomcat server, establishes own first servlet program.
the theoretical and other knowledge related to Java Web Development is not discussed here. Some common errors are addressed at the end of the article. 1. Teach you to build your first servlet
The following actions do not work when you run MyEclipse as an administrator under Win7, otherwise they are not valid. Apply it where you need it in the dialog box, making sure that the browser address bar and the file you created are spelled correctly. This step is also suitable for the XP system, but the XP system does not have the problem of permissions, more simple and easy to use.
Step1:MyEclipse Connect Tomcat first to ensure the installation of MyEclipse, Tomcat and Java JDK, the author installs the version is MyEclipse 8.5,tomcat 6.0,jdk 1.7. MyEclipse Connect Tomcat, select the MyEclipse "window"--"Preferences" menu item, open the interface as shown in 1: Figure 1 set MyEclipse and Tomcat connection Select the installation path for Tomcat, Then select Enable.
STEP2:Set the JDK version. To set the JDK version, you need to select the JDK option, then select Add a directory for the JDK installed on the system and select the JDK version of your system in the drop-down list. The operation is shown in 2: Figure 2 Setting the JDK version
STEP3:New Web project with MyEclipse new web as shown in 3:
Figure 3 Creating a new Web project interface
When you are finished creating the project file view in Project Explorer as shown in 4:
Figure 4 Project Resource Browse view
STEP4:Deploying Web Apps with MyEclipse (Deploy: Deployment, configuration meaning) deployment can start with the Deploy button in the toolbar, as shown in 5:
Figure 5 Starting a deployment app
The deployment process needs to select the server to deploy, here we choose tomcat6.x, as shown in 6:
Figure 6 Selecting a deployment server
When the deployment is complete, as shown in 7:
Figure 7 End of deployment
Click the button browse to see some more files in the Tomcat installation directory, as shown in 8:
Figure 8 New files after deployment
STEP5:Start the Tomcat server method one: Start from the toolbar "run". Select Start as a Web service program, as shown in 9:
Figure 9 Starting the Web service program from the toolbar
Then choose Start from tomcat6.x, as shown in 10:
Figure 10 Selecting the tomcat6.x server
Method Two: Start from the Servers panel card ([window]--[show view]--[servers] found), as shown in 11:
Figure 11 starting the Tomcat server
If the deployment and server startup are successful, you can enter http://localhost:8080/FirstServlet/index.jsp in the browser and test successfully, as shown in 12:
Figure 12 Test success
STEP6: Creating a servlet file
Create a servlet file such as 13, figure 14, and Figure 15:
Figure 13 Selecting the servlet file type
Figure 14 fill in the relevant class name
Figure 15 New completion
Here is a system that test.java the files we generated and changes the corresponding configuration in Web. Xml.
STEP7: Testing the servlet program
We enter the address of the browser address bar according to the Url-pattern in the Web. xml file. The Url-pattern is shown in Web. 16:
Figure 16web.xml in the Url-pattern
In the browser re-entry: Http://localhost:8080/FirstServlet/servlet/Test, the test succeeds as shown in 17:
Figure 17 Test success 2. Errors and Workarounds Error 1: A configuration error occurred during Startup.please Verify the Preference field with the PROMPT:TOMCA T jdk name. WORKAROUND: Select the JDK option when configuring Tomcat and then configure it to the JDK based on the JDK version installed on the system, as described in the section above. Error 2:the APR based Apache Tomcat Native Library which allows optimal performance in production environments is not found On the Java.library.path fix: Missing Tcnative-1.dll file, you need to copy Tcnative-1.dll to Tomcat's Bin directory. Error 3:an incompatible version 1.1.12 of the APR based Apache Tomcat Native Library is installed, while Tomcat requires Versi On 1.1.17.
Resolution: Increase the Tcnative-1.dll version. Error 4:error initializing endpoint,address already in use:
Workaround: Make sure that the port is not occupied, modify the Tomcat's use port, specifically-find the directory .../tomcat 5.5/conf, in the Conf directory there is a "server.xml" file, open this file with Notepad, find (open file after ctrl+f) file all "8080" and change to other port values that are not occupied (e.g. 8088, 8081, etc.).
It's over. If there is, it is possible that Tomcat is running again or another program, you can use NETSTAT-ANB to view the process that occupies the port, and then resolve the process, such as taskkill/f/im Tomcat6.exe.
Error 5: Operate as described above, but the results do not come out. Workaround: Run MyEclipse as an administrator under Win7, which is where I am trapped. Reference: http://blog.csdn.net/wangdingqiaoit/article/details/7674367
"Go" myeclipse the first servlet program--Solve the MyEclipse and Tomcat connection problem under the Win7 system