The simple configuration of Tomcat and the application of the default Web App

Source: Internet
Author: User

Specify the Tomcat port:
Server.xml:
<connector port= "8080" protocol= "http/1.1"
connectiontimeout= "20000"
redirectport= "8443"/>
To open the Servlet debugger:
Open the following code comment for the Web. XML under Tomcat conf:
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
Allows the servlet to run without modifying the Web app's Web-inf/web.xml file. You only need to copy the servlet to the Web-inf/classes directory, using the URL http://host/servlet/ServletName (the default Web app) or http://host/webAppPrefix/ Servlet/servletname (custom web App) you can use it
Test whether Tomcat and JDK are well-configured:
Run tests on your computer, you can use localhost in the URL of host
Tomcat html/jsp Directory:
Install_dir/webapps/root (or Install_dir/webapps/root/somedirectory)
Write hello.html and hello.jsp into the root directory under Tomcat under WebApps, using localhost:8080/hello.html and other access
You can also place the servlet there, and if the servlet is placed under a package, the server must have a directory that matches the package name. and the access package name in the browser is used. Delimited
Http://localhost:8080/servlet/HelloServlet
Http://localhost:8080/servlet/com.zhen.test.o1.HelloServlet2

When you use TOMCAT6 to open the Servlet debugger, Tomcat initiates an error:
Servlet of Class Org.apache.catalina.servlets.InvokerServlet is privileged and cannot are loaded by this Web application
You need to add two attributes to the Tomcat/context.xml:
Reloadable= "true" privileged= "true"

Simplify the way you deploy Tomcat:
1. How to copy shortcut paste
Source code files are not expected to appear on the real deployment server
2. javac-d parameter can specify the compilation location of Javac
Javac helloworld.java-d D:
3. Use IDE to complete deployment
4. Using Ant or similar tools

Default Web App Deployment:
Tomcat:
HTML and JSP pages:
Main position:
Install_dir/webapps/root
The corresponding URL:
Http://host/SomeFile.html
Single servlet and utility class files
Main position:
Install_dir/webapps/root/web-inf/classes
The corresponding URL (servlet):
Http://host/servlet/ServletName
More specific locations (classes in the package):
Install_dir/webapps/root/web-inf/classes/packagename
The corresponding URL (the servlet in the package)
Http://host/servlet/packageName.ServletName
Servlet and Utility class files bundled in the jar file
Position:
Install_dir/webapps/root/web-inf/lib
The corresponding URL (servlet):
Http://host/servlet/ServletName
Http://host/servlet/packageName.ServletName

The simple configuration of Tomcat and the application of the default Web App

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.