Download Steps To Create JSP Application Using Tomcat

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

URL redirection wikipedia , lookup

Transcript
Run-your-first-JSP-in-Tomcat-Server
A) If you already have Tomcat in your system say as tomcat7,
just copy into notepad and save the following text as
clock.jsp (saveAs type all files, while saving) in
tomcat7/webapps/ROOT folder
<html ><head> <title>A Simple JSP Example</title>
<style type = "text/css">
.big { font-family: helvetica, arial, sans-serif;
font-weight: bold;
font-size: 2em; }
</style>
</head>
<body>
<p class = "big">Dr Sastry's Simple JSP Example</p>
<table style = "border: 6px outset;">
<tr>
<td style = "background-color: black;">
<p class = "big" style = "color: cyan;">
<!-- JSP expression to insert date/time -->
<%= new java.util.Date() %>
</p>
</td>
</tr>
</table>
</body> </html>
Then Start Tomcat and in browser type
http://localhost:8080/clock.jsp
That’s all , your jsp works fine and displays time.
OR
If you don’t have Tomcat etc., Then do as follows
Note: The above material is added by Dr. Peri Sastry
Run your first JSP program in Apache Tomcat Server
Amit Diwan, 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.
Step1
Install Java.
Step2
Install
Apache
At the time of installation, it will by-default recognize JRE path.
(under installed java location directory)
Step3
Now Go-To:

Start

Programs

APACHE TOMCAT

MONITOR TOMCAT
Tomcat
Step4
An icon will appear on the taskbar, this icon will automatically appear after
following above step:
Step5
Click on that icon and START TOMCAT, you can see the following dialog box:
Step6
Now open Mozilla Firefox(or any other browser)
Step7
Type http://localhost:8080/ on address bar and press enter.
The same can be seen here:
Step8
It will show tomcat, as shown in above window.
(if not, then try again, may be a problem in installation or you’re not following
above steps correctly
Step9
Now, go to:

C:drive

Programs Files

Apache Software Foundation

tomcat

web-apps
(or navigate where you have installed APACHE TOMCAT)
Step10
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

Step11
Create a text file and name it as first.jsp, use the code shown below:
<html>
<head>
<title>blog post:ApacheTomcatServer</title>
</head>
<body>
<%-- 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.
Step12
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.