This article mainly introduces the introduction of tomcat, and introduces tomcat and the basic configuration of Tomcat in detail. It has certain reference value. Those who are interested can learn about it
tomcat introduction:
The web server can only complete requests for static resources;
The web container can request dynamic resources;
tomcat is the simplest web container and is a sub-project of Apache's jarkata project.
tomcat 7.0.X supports the Servlet 3.0 specification, so it is recommended to use 7.0.X;
tomcat has two versions:
(1) Binary version: Environment variables need to be configured after decompression. It is recommended to use this version.
(2) Service version: executable file, the service will be registered in the system after installation.
tomcat directory introduction:
tomcat has Several folders:
(1)bin: stores executable commands, such as opening and closing tomcat: startup.bat;
(2)conf: configuration file.
(3)webapps: Publish web applications.
(4)lib: library file, which can be expanded through this directory, such as placing the database driver in this file.
(5)work: Temporary Java or class file.
Tomcat basic configuration
Note: Do not place Tomcat in a Chinese directory or a directory with spaces;
1. Configure environment variables
1. Configure JAVA_HOME: C:\Java\jdk1.6.0_27
2. Configure CATALINA_HOME: C:\ apache-tomcat-7.0.6 (This environment variable does not need to be configured)
Take my configuration as an example and adjust it according to your own installation location;
catalina_home is configured In the future, when the situation as shown in the figure appears:
When you click C:\tomcat\bin\startup.bat, D:\tomcat
##2. Configure the port
The default is 8080, which can be configured in tomcat/conf/server.xml.
<Connector port="8888" protocol="HTTP/1.1" //此处可以把8888换成任意端口. connectionTimeout="20000" redirectPort="8443" />After configuring these, you can already use tomcat. Enter http://localhost:8888 in the browser and the following page will pop up:
Port Occupied problem:
Solution:
3. Configure user roles
<role rolename="manager-gui"/> <user username="admin" password="12345" roles="manager-gui"/> //用户名为admin,密码为12345JAAS: Java Authentication Authorization Service, that is, Java Authentication Authorization Service
4. Configure and deploy web application path
1. You can deploy it in the webapps directory, that is, copy the entire web application directly to webapps.<?xml version="1.0" encoding="GBK"?> <Context docBase="F:/publish" debug="0" privileged="true"> //docBase是路径,可以自己调整 </Context>In this way, you can enter http://localhost:8080/test to access. Note that test is the name of the xml file.
##
<param-name>listings</param-name> <param-value>false</param-value>改成true
3. Configure the default homepage: in The last
in conf/web.xml
<welcome-file>index.html</welcome-file>
说明默认为index.html,因此如果输入http://localhost:8080/test则会自动调用index.html.
4.每个web应用中都需要WEB-INF和web.xml文件,最简单的办法就是去tomcat主目录下的webapps/ROOT/的WEB-INF拷贝到你所需要的web应用文件夹下。
5.第一次用户请求某个JSP会比较慢。
原因:JSP首先会转换成JAVA文件,然后再编译成class文件,最后才执行,这些java和class的文件都在tomcat主目录的work文件夹下。
HTTP常见状态:
(1)404错误:客户路径不正确造成。
(2)500错误:服务器内部错误。
因此总的来说:
(1)2##:请求成功。
(2)4##:客户端错误。
(3)5##:服务器错误。
JSP文件简介:HTML+JAVA代码。
中嵌入java代码。
在html中
The above is the detailed content of A brief introduction to tomcat in Java. For more information, please follow other related articles on the PHP Chinese website!

The article discusses using Maven and Gradle for Java project management, build automation, and dependency resolution, comparing their approaches and optimization strategies.

The article discusses creating and using custom Java libraries (JAR files) with proper versioning and dependency management, using tools like Maven and Gradle.

The article discusses implementing multi-level caching in Java using Caffeine and Guava Cache to enhance application performance. It covers setup, integration, and performance benefits, along with configuration and eviction policy management best pra

The article discusses using JPA for object-relational mapping with advanced features like caching and lazy loading. It covers setup, entity mapping, and best practices for optimizing performance while highlighting potential pitfalls.[159 characters]

Java's classloading involves loading, linking, and initializing classes using a hierarchical system with Bootstrap, Extension, and Application classloaders. The parent delegation model ensures core classes are loaded first, affecting custom class loa


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function