• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Servlet mapping problem ...

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Destroy anything that stands in your way. Except this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic