tags:

views:

109

answers:

2

I have a Java Web application that has several servlets with the following mappings.

ServletOne -> /one
ServletTwo -> /two
ServletThree -> /three

When I make a request for an action that doesn't exist I get a 403 (Forbidden), ie: /foo. I would like to change that to give a 404 (Not Found). How can I do that?

If getting a 404 is default behavior, then where can I look for that setting that's throwing things off? I tried googling for this, but I wasn't able to come up with a search query that yielded anything related.

TIA!

+4  A: 

Have a servlet map to / (which will capture everything) and then make that return a 404 in the doGet/processRequest calls. That way you won't rely on any specific behaviour of the app server you're using to configure it.

AlBlue
A: 

What servlet container are you using?

Tomcat, by default, maps /* to DefaultServlet (according to the $TOMCAT_HOME/conf/web.xml) for the server, which I just confirmed will throw a 404 by default if the mapping doesn't exist.

I would suggest starting by looking at your servlet container's web.xml file to see if a similar default mapping exists.

KG
My container is WebSphere 6.1
dharga