Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running jsp files with Apache tomcat on windows

I installed Apache Tomcat on my Windows machine, and it seems like its installed successfuly. I can see the property window, and I can start the server but I don't know what to do next.

Where do I save jsp files at.. do I create a directory or does apache tomcat create its own directories?

that's my only problem.. how do i make and edit files now that its installed

like image 938
ruben Avatar asked Jan 08 '11 07:01

ruben


3 Answers

Create the JSP code that you'd like to write in your favorite text editor.

Select "File" and "Save As" from the text editor toolbar. A dialog box appears.

Navigate to the "File name" text field and type the desired file name within quotes. Add a JSP extension to the file name -- for example, "filename.jsp" -- and click "Save."

Put it at location C:\apache-tomcat-7.0.28\webapps\ROOT.

Go to tour browser and enter url "http:// localhost:8080//filename.jsp"

like image 84
Shailesh Kumar bhardwaj Avatar answered Nov 12 '22 05:11

Shailesh Kumar bhardwaj


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

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/][1] 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/][2]foldername.extension in any WebBrowser i.e:

[http://localhost:8080/amit2012PROJECT/first.jsp][3]

The Project will run successfully

Now, you can successfully try running JSP with ApacheTomcatServer.

like image 21
Sathish Avatar answered Nov 12 '22 05:11

Sathish


Folder structure:

 Apache-home/webapps/project_name/WEB-INF/classes

all jsp filse should come under project_name folder. and java classes comes under clasess. Also need to put a special file named web.xml in WEB-INF folder.

like image 31
Harry Joy Avatar answered Nov 12 '22 04:11

Harry Joy