aspose file tools*
The moose likes Tomcat and the fly likes Servlet mapping problem ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Servlet mapping problem ..." Watch "Servlet mapping problem ..." New topic
Author

Servlet mapping problem ...

Stef Mischook
Greenhorn

Joined: Nov 12, 2004
Posts: 15
I have a servlet that is mapped like so:

<servlet-mapping>
<servlet-name>loginResponse</servlet-name>
<url-pattern>/loginResponse</url-pattern>
</servlet-mapping>

And I have a form that submits to the servlet:

<form action="/loginResponse" method="post">

But I'm getting a 404 ... any suggestions?

I'm using Tomcat 5 integrated with Apache on Linux.

Thanks,

S


<a href="http://www.killersites.com" target="_blank" rel="nofollow">http://www.killersites.com</a><br /><a href="http://www.how-to-build-websites.com" target="_blank" rel="nofollow">http://www.how-to-build-websites.com</a><br /><a href="http://www.websitetemplates.name" target="_blank" rel="nofollow">http://www.websitetemplates.name</a>
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

If the application is not the default application (which from your other post, it might not be...), you need to also include the webapp context path in your POST action.

So if your page is here:
http://www.foo.com/foobar/form.html

you'll need to have a form action that reads:

<form action="/foobar/loginResponse" method="post">

This is also assuming that you have a servlet element in your web.xml that matches the servlet-mapping you're showing us.
Stef Mischook
Greenhorn

Joined: Nov 12, 2004
Posts: 15
Hi,

It's interesting that you mention that because when testing the web-app on my local installation of Tomcat (standalone)as a sub-context this form works fine:

<form action="loginResponse" method="post">

The form pages' url is:

http://127.0.0.1/myWebsite/logIn.jsp

The servlet mapping is :

<servlet>
<servlet-name>loginResponse</servlet-name>
<servlet-class>com.myApp.authenticateAdmin</servlet-class>

</servlet>

<servlet-mapping>
<servlet-name>loginResponse</servlet-name>
<url-pattern>/loginResponse</url-pattern>
</servlet-mapping>

Yet on the live server where Tomcat is integrated with Apache I get the 404. So I changed the form to:

<form action="/loginResponse" method="post">

But still 404 ... any ideas?

Thanks,

S
Logan Owen
Greenhorn

Joined: Dec 01, 2004
Posts: 24
I maybe way off mark...but is Apache even forwarding the request on to Tomcat? I mean, I though Apache only forwarded pages that had the .jsp suffix automatically, so you would need further Apache configuration to forward a servlet request. Just a thought...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Servlet mapping problem ...
 
Similar Threads
404 error when accessing servlet?
Servlet Mapping doesn't work in Tomcat 5.5
Servlet doesn't pick initial parameter
Problem with more than one url-mapping
Tomcat not seeing servlet