Tomcat server, tomcat

Source: Internet
Author: User

Tomcat server, tomcat

1. concept:

Tomcat is an application (java) server and a servlet container. It supports Servlet and JavaServer Page (JSP) and provides some special functions as Web servers, such as Tomcat Management and Control Platform and security domain management. Because Tomcat itself contains an HTTP server, it can also be considered as a separate Web server.


2. Use

Download: You can download it from the official website or click to download the uploaded resources: apache-tomcat-5.5.26 or apache-tomcat-7.0.42.

Directory: Open the directory description corresponding to the downloaded file

Bin:Stores script files for starting and disabling Tomcat on various platforms.
Common:The lib directory under the common directory stores the JAR files that can be accessed by the Tomcat server and all web applications.
Webapps:The release directory of the web application. Put the web site or war file developed by java into this directory and you can access it through the tomcat server.
Conf:The most important configuration file for Tomcat is server. xml.
Conf/server. xml server master configuration file
Conf/web. xml defines the configuration of all Web Applications
Conf/tomcat-user.xml defines tomcat user information (for permission and security)

Environment variable:

1. java_home

ClickBinDirectoryStartup. batWhen you start tomcat, the command window is not displayed when you click it, because the environment variable java_home is not configured and the installed java. jdk directory is configured. I configured java_home but still cannot start it.

Finally, manually set JAVA_HOME = C: \ Program Files \ Java \ jdk1.8.0 _ 40 in startup. bat to run the web Program.



2. classpath

Because Servlet is not part of the Java platform Standard Edition, you must specify the Servlet class path for the compiler.

Add \ servlet-api.jar at the end of your corresponding directory.



If this parameter is not referenced, an error occurs during javac program Compilation: NO content is found.


3. web application:

Put your own in webappsWeb Project (text_servlet)


Text_servlet directory structure

WEB-INF

Classes: place the generated java. class File

Lib: add the jar package to be used

Web. xml: Configure servlet Information:

Html or jsp

Web. xml configuration file

<Span style = "font-family: SimSun; font-size: 14px;"> <? Xml version = "1.0" encoding = "ISO-8859-1"?> <Web-app xmlns = "http://java.sun.com/xml/ns/j2ee" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemaLocation = "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version = "2.4"> <servlet-name> MyServlet </servlet-name> <! -- Name defined by myself --> <servlet-class> LoginServlet </servlet-class> <! -- Actual java classes in the classes directory --> </servlet> <servlet-mapping> <servlet-name> MyServlet </servlet-name> <! -- Name defined by myself, above --> <url-pattern>/loginServlet </url-pattern> <! -- Configuration name, which is called by the client --> </servlet-mapping> </web-app> </span>

Conf/server. xml Some settings in
Default port = 8080, maxThreads = 150 maximum number of threads.


Other directories in Tomcat:

Shared: the lib directory under the shared directory stores the JAR files that can be accessed by all web applications but cannot be accessed by Tomcat.
Server: In the server/webapps directory, store two APP-admin and manager applications that come with Tomcat to manage Tomcat-web Services.
Work: Tomcat stores various servlet files generated by jsp in this directory.
Temp: Temporary binder used to store temporary files during Tomcat running.
Logs: stores Tomcat log files.


3. Summary:

Tomcat acts as the servlet container and manages the servlet lifecycle. The following section describes the working process of Tomcat in web running through a login instance, after I started using Tomcat, I made corresponding supplements as I learned more deeply.

Copyright Disclaimer: the shortcomings of this article are inevitable. Please comment and comment on them.

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.