Solved

Apache Tomcat and jsp

Posted on 2006-06-29
3
494 Views
Last Modified: 2010-04-01
Hi all

I installed the following:

JavaTM 2 Platform Standard Edition
Development Kit 5.0

I then installed Apache Tomcat 5.x

I also loaded the Apache JDK 1.4 Compatability Package

I got some java servlets up and running ok.  I can invoke them from a html page.

Now I want to run jsp pages.

I have a simple html page with the following line:

<form id="form2" method="get" action="simple.jsp">

The simple.jsp is as follows:

<html>
<head>
<title>Simple JSP Page</title>
</head>
<body>
<h2>Request Origin</h2>
Host Name: <%= request.getRemoteHost() %>
<br>
IP Address: <%= request.getRemoteAddr() %>
</body>
</html>

When I submit the form to call this jsp page, the browser wants to open the actual jsp file in an editor, rather than invoking it.

I guess apache is not responding to this request.

When I look at /conf/web.xml fine in apache it does include the following:

    <!-- The mapping for the JSP servlet -->
    <servlet-mapping>
        <servlet-name>jsp</servlet-name>
        <url-pattern>*.jsp</url-pattern>
    </servlet-mapping>

Can anyone tell me where I am going wrong?

Thanks, Phil

0
Comment
Question by:pmccar06
3 Comments
 
LVL 3

Accepted Solution

by:
runa_paathak earned 125 total points
ID: 17008949
Forget about conf/web.xml, that is not relevant to your problem.

Create a folder like "myapp" in Tomcat's webapps folder. Place your html file and jsp file in this folder. Start tomcat; once tomcat server is up and running, access the html page with a url like this:

http://localhost:8080/myapp/yourhtmlpage.html.

The broswer is opening the jsp directly because you are not running Tomcat server and you don't have your webapp set up properly.
0
 
LVL 27

Expert Comment

by:rrz
ID: 17009325
>I also loaded the Apache JDK 1.4 Compatability Package  
Why did you do that ?   Don't use it. You are using java 5 and it is not for you.  
><form id="form2" method="get" action="simple.jsp">  
change to  
<form id="form2" method="get" action="http://localhost:8080/yourWebAppName/simple.jsp">
I have assumed that you left the default port 8080 and you have placed  simple.jsp into the root directory of your web app.


0
 
LVL 35

Expert Comment

by:TimYates
ID: 17016306
I wouldn't do that to the form tag :-/
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
With the rapid rise in mobile usage, mobile devices are here to stay and have become an integral part of doing business. Here are 9 great apps for your BYOD environment.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now