About

Blogger Tips and TricksLatest Tips For BloggersBlogger Tricks

Blogger Tips and TricksLatest Tips For BloggersBlogger Tricks

Friday 7 July 2017

Run your first JSP program in Apache Tomcat Server

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 Tomcat
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

amit2012 blog

Step4

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

amtdw2012 blog


Step5

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

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:
amit2012 blog

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:

amit2012 blog

Now, you can successfully try running JSP with ApacheTomcatServer.

0 comments:

Post a Comment