Vous êtes sur la page 1sur 5

Run your first JSP program in Apache Tomcat Server

1 of 5

Amit Diwan

http://www.tutorialspoint.com/articles/run-your-first-jsp-program-in-a...

, Posted on October 15, 2012, filed in: Web Design

This post will give you description about how you can run your project using Apache
Tomcat Server.
I would like to define these terms before proceeding:
Apache Tomcat Server(Jakarta Tomcat): It is an open source web server and servlet
container developed by the Apache Software Foundation (ASF). It implements the Java
Servlet and the JavaServer Pages (JSP) specifications and provides a pure Java HTTP web
server environment for java code to run.
JavaServerPages(JSP): It is a technology that helps in creating dynamically generated
web pages.

Install Java.

Install Apache Tomcat


At the time of installation, it will by-default recognize JRE path.
(under installed java location directory)

Now Go-To:
Start
Programs
APACHE TOMCAT
MONITOR TOMCAT

16-11-2016 11:22

Run your first JSP program in Apache Tomcat Server

2 of 5

http://www.tutorialspoint.com/articles/run-your-first-jsp-program-in-a...

An icon will appear on the taskbar, this icon will automatically appear after following
above step:

Click on that icon and START TOMCAT, you can see the following dialog box:

Now open Mozilla Firefox(or any other browser)

Type http://localhost:8080/ on address bar and press enter.


The same can be seen here:

16-11-2016 11:22

Run your first JSP program in Apache Tomcat Server

3 of 5

http://www.tutorialspoint.com/articles/run-your-first-jsp-program-in-a...

It will show tomcat, as shown in above window.


(if not, then try again, may be a problem in installation or youre not following above steps
correctly

Now, go to:
C:drive
Programs Files
Apache Software Foundation
tomcat
web-apps

(or navigate where you have installed APACHE TOMCAT)

Open web-apps and copy your project or make new folder, which you want to run in
JSP.
Example: amit2012PROJECT
Now, go back :
Tomcat
Root
Copy Web-inf from root
Paste this web-inf in your project folder i.e. amit2012PROJECT

Create a text file and name it as first.jsp, use the code shown below:
<html>
<head>
<title>blog post:ApacheTomcatServer</title>
</head>
<body>

16-11-2016 11:22

Run your first JSP program in Apache Tomcat Server

4 of 5

http://www.tutorialspoint.com/articles/run-your-first-jsp-program-in-a...

<%-- START --%>


<%
out.println("UserName = amit2012, ");
out.println("Running first program in JSP.");
%>
<%-- END --%>
</body>
</html>

It includes HTML tags and encloses a JSP scriptlet which is a fragment of Java code that
is run when the user requests the page.

Now for running your folder [ Eg. amit2012PROJECT as shown above]


http://localhost:8080/foldername.extension in any WebBrowser i.e:
http://localhost:8080/amit2012PROJECT/first.jsp

The Project will run successfully, as shown below:

Now, you can successfully try running JSP with ApacheTomcatServer.


Next
Advertisements

16-11-2016 11:22

Run your first JSP program in Apache Tomcat Server

5 of 5

http://www.tutorialspoint.com/articles/run-your-first-jsp-program-in-a...

16-11-2016 11:22

Vous aimerez peut-être aussi