Tomcat IntroductionTomcat is a core project of the Jakarta project of the Apache Software Foundation, developed jointly by Apache, Sun and some other companies and individuals. Thanks to Sun's participation and support, the latest Servlet and JSP specifications can always be reflected in Tomcat. Tomcat 5 supports the latest Servlet 2.4 and JSP 2.0 specifications. Because Tomcat has advanced technology, stable performance, and is free, it is deeply loved by Java enthusiasts and recognized by some software developers, becoming a relatively popular Web application server. Tomcat deployment Download Tomcat According to the system type of your computer, select the 64-bit or 32-bit compressed package and decompress it. After decompression Open IDEA, click 4. Click Creating a web projectFirst create an empty java project and take a screenshot here Right click the project and click This will add a web directory to the project Configure tomcat If your error is not automatically handled here, it means that you did not do the previous step of configuring the web application. ( Habit ) Create two folders under WEB-INF: classes and lib Configuring the project architecture Click OK ( habit ) Change Application context Successful connection The index.jsp file will be opened automatically. Because index.jsp is the default homepage, there is no need to write a virtual directory. If you access other .html files, you need to write the file name after localhost:8080 (such as: localhost:8080/hello.html) You can create a .java file under src and implement the servlet interface and its 5 methods, and write an output code under the service method, which will be used later. Configuring the servletMethod 1: Paste the following code in web.xml <!--Configure servlet--> <servlet> <servlet-name>demo1</servlet-name> <servlet-class>cn.utkvrjan.web.servlet.ServletDemo1</servlet-class> </servlet> <servlet-mapping> <servlet-name>demo1</servlet-name> <url-pattern>/demo</url-pattern> </servlet-mapping> Paste it in the position shown in the picture Method 2: Starting from Servlet 3.0, annotation configuration is supported. It is super simple. Just write Then start tomcat and enter localhost:8080/demo1 in the browser to access (Note: demo1 here is entered when configuring the servlet). The content you wrote under the service method of the servlet implementation class will be output in the IDEA console, which means that the servlet is configured correctly. (Habit) Hot deployment : Change Tomcat to: When updating resources in the file, let Tomcat restart (re-deploy the project), so that you don't need to manually restart the server after changing the file, which is more convenient. If you select Update resources and classes here, you will also need to redeploy when you change the Java code. Since there are many changes to the Java code, this may affect performance, so don't select it. This is the end of this article about deploying Tomcat in IDEA 2020.3.1 and creating the first web project. For more information about deploying Tomcat in IDEA 2020.3 and creating the first web project, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed explanation of MySQL backup and recovery practice of mysqlbackup
>>: How to implement responsive layout with CSS
Project Background Recently, there is a project w...
Robots.txt is a plain text file in which website ...
Due to business needs, there are often rush purch...
In higher versions of Tomcat, the default mode is...
question: When I was doing project statistics rec...
Nowadays we often talk about Web2.0, so what is W...
To perform incremental backup of the MySQL databa...
Preface There are often some articles on the Inte...
Table of contents Preface Publish-Subscriber Patt...
Table of contents 1. Switch between production en...
In the Docker system learning tutorial, we learne...
This article shares the specific code of JavaScri...
This article example shares the specific code of ...
In Linux systems, especially server systems, it i...
In the front-end design draft, you can often see ...