Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure the environment of tomcat

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "how to configure the environment of tomcat", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to configure the environment of tomcat" article.

Tomcat introduction:

The web server can only complete requests for static resources

Web container can make requests for dynamic resources

Tomcat is the simplest web container and is a subproject of apache's jarkata project.

Tomcat 7.0.x supports the servlet 3.0 specification, so 7.0.x is recommended

There are two versions of tomcat:

(1) binary version: you need to configure environment variables after decompression. It is recommended to use this version.

(2) Service version: executable file, after installation, the service will be registered in the system.

Introduction to the tomcat directory:

Tomcat has several folders:

(1) bin: stores executable commands, such as turning on and off tomcat:startup.bat

(2) conf: configuration file.

(3) webapps: publish web applications.

(4) lib: library files, which can be extended through this directory, such as placing database drivers in this file.

(5) work: temporary java or class file.

Basic configuration of tomcat

Note: tomcat should not be placed in Chinese directories or directories with spaces

I. configure environment variables

1. Configure java_home: C:\ java\ jdk1.6.0_27

two。 Configure catalina_home:c:\ apache-tomcat-7.0.6 (this environment variable may not be matched)

Here, take my configuration as an example, adjust according to your own installation location.

After catalina_home is configured, when the situation as shown in the figure appears:

When you click c:\ tomcat\ bin\ startup.bat, you start d:\ tomcat.

2. Configure ports

The default is 8080, which can be configured in tomcat/conf/server.xml.

After configuring these, you are ready to use tomcat. Enter http://localhost:8888 in the browser and the following page pops up:

Port occupied problem:

If other software occupies this port, it will cause tomcat not to start.

Solution:

Check the port usage with software such as fport, and then kill this process.

3. Configure user roles

In order to manage and deploy web applications on the page, you must have users, so you need to configure new users and passwords (originally no users).

Add the following statement in tomcat/conf/tomcat-users.xml:

/ / user name is admin and password is 12345

Jaas:java authentication authorization service is the java authentication authorization service.

As shown in the figure, you can log in using the user name and password set above:

4. Configure and deploy web application path

1. It can be deployed in the webapps directory, that is, the entire web application is copied directly to the webapps.

two。 You can create a test.xml in the conf/catalina/localhost directory and add to this file:

/ / docbase is the path, which can be adjusted by yourself.

This can be accessed by typing http://localhost:8080/test. Note that this test is the name of the xml file.

For example, if the name of the xml file is x.xml, enter http://localhost:8888/x

You also need to create a new web-inf folder in f:\ publish, that is, the directory of the web application, and create a new web.xml in this folder. In order to be lazy, you can paste tomcat/webapps/web-inf/web.xml files into f:\ publish\ web-inf.

3. Can be deployed in a web page, as shown in the figure:

You can deploy through the war package or a path, and the war package can be exported from eclipse.

Common points for attention:

1. Set the port number: modify it in conf/server.xml.

two。 Configure virtual directories: add them last in conf/server.xml

For example, typing http://localhost:8080/test in the browser can run the contents of d:\ test.

Note: after the configuration, it will be in the conf/web.xml.

Change listingsfalse to true

3. Configure the default home page: last in conf/web.xml

Index.html

The specification defaults to index.html, so if you enter http://localhost:8080/test, index.html will be called automatically.

4. Every web application needs web-inf and web.xml files. The easiest way is to copy the web-inf of webapps/root/ under the tomcat home directory to the web application folder you need.

5. The first time a user requests a jsp will be slow.

Reason: jsp is first converted into java files, then compiled into class files, and then executed. These java and class files are in the work folder of the tomcat home directory.

Common http status:

(1) 404 error: incorrect customer path.

(2) 500 error: server internal error.

So on the whole:

(1) 2 requests: request is successful.

(2) 4 clients: client error.

(3) 5 errors: server error.

Introduction to jsp file: html+java code.

Embed java code in.

The action property in html sets the jsp file on which the server processes the request, for example:

Next is the simplest application tomcat program, the user enters any string such as world, the server returns hello plus a string, such as hello,world.

Demo input:

Jsp file:

Demo

Web application directory layout recommendations:

Home directory | |-web-inf | |-web.xml | |-classes |-place class file | |-lib |-place a third-party jar package | |-src |-store source files |-store jsp and html | |-image |-the above is about the article "how to configure the tomcat environment". I believe everyone has a certain understanding. I hope the content shared by the editor will be helpful to all of you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report