Eclipse4.5 (Mars) for Java EE Edition
TOMCAT8 installation, setting Java_home environment variables
Establish Dynamic Web project, which targets the TOMCAT8 server.
Note: When creating a project, select Generate Web. xml
-------------------------------------
Right-click on Project, New, servlet
Name: Hello, inherit HttpServlet, package name: Gyh.serv
To modify the Java file, add the Doget method:
Response.getwriter (). Write ("Simple Hello");
Save.
Modify the web.xml,<web-app> tag to add information:
<servlet> <Servlet-name>Haha</Servlet-name> <Servlet-class>Gyh.serv.Hello</Servlet-class> </servlet> <servlet-mapping> <Servlet-name>Haha</Servlet-name> <Url-pattern>/hhh</Url-pattern> </servlet-mapping>
What it does: give the Hello class an individual name and associate the alias to a URL address.
Java file, right-click, run, run on the server, you can see the effect of the browser output.
---------------------------
Web project, right-click, Export,war file,
Select the items you want to export, and where the war files need to be stored. is automatically packaged as a war file. This is the war package.
The war file is copied to Tomcat8 's WebApps directory, even if it is published.
Start Tomcat8 on the console (with Startup.bat, it's okay with Eclipse)
In the browser, enter: Http://127.0.0.1:8080/web_test_2/hhh
Should be able to see the effect.
Stop the server (shutdown.bat), delete the war package under WebApps, and go back to the original point.
Eclipse Tomcat8 Write a servlet