Home > Java > javaTutorial > body text

How to run jsp files in tomcat

(*-*)浩
Release: 2020-09-15 16:01:00
Original
24823 people have browsed it

Running method: 1. In the bin folder of the Tomcat installation directory, run the "startup.bat" file to start Tomcat; 2. Place the JSP file in Tomcat's webapps folder; 3. Browse Just enter "http://localhost:8080/JSP file path" in the address bar of the server.

How to run jsp files in tomcat

What we introduce here is purely using tomcat to run jsp files. It will be more convenient if you use ide tools, such as eclipse, you need to configure tomcat to Inside, deploy the jsp project to tomcat, and you can access the page. The premise is that you do not impose URL restrictions, otherwise you will have to access it according to the requirements.

Recommended course: Java Tutorial.

1. Start Tomcat:

In the bin folder under the Tomcat installation directory, run the startup.bat batch file. The screenshot is as follows:


A window will pop up automatically:


Do not close this window .

2. Test whether Tomcat starts successfully.

Open the browser and enter http://localhost:8080 (Tomcat’s default port is 8080) in the address bar. If you see Tomcat’s welcome interface in the browser, it means Tomcat Works fine. The screenshot is as follows:


#3. Prepare the JSP file.

1.jsp file source code:

<span style="font-size:14px;"><%@ page contentType="text/html; charset=gb2312" language="java" %>  
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>  
<HTML>  
<HEAD>  
<TITLE>第一个JSP页面</TITLE>  
</HEAD>  
    <BODY>  
  
    <%for(int i=0;i<10;i++)  
    {  
        out.println(i);  
        %>  
    <br/>  
        <%}%>  
    </BODY>  
</HTML>
Copy after login

4. Associate the JSP file with Tomcat.

Put the JSP page that has been written into the webapps folder of the Tomcat folder. Here, create a new folder Me in webapps and put the 1.jsp file into it. The screenshot is as follows:


4. Use Tomcat to run the JSP file.

Open the browser and enter http://localhost:8080/Me/1.jsp in the address bar. If successful, the browser page will display the running results of the 1.jsp file. Screenshot below:

The above is the detailed content of How to run jsp files in tomcat. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template