Solved

Apache Tomcat and jsp

Posted on 2006-06-29
3
484 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

We have come a long way with backup and data protection — from backing up to floppies, external drives, CDs, Blu-ray, flash drives, SSD drives, and now to the cloud.
Use of TCL script on Cisco devices:  - create file and merge it with running configuration to apply configuration changes
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

24 Experts available now in Live!

Get 1:1 Help Now