Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet mapping problem ...

 
Stef Mischook
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic