Getting the original URL in a custom 404 error page/servlet (Tomcat)

A

Anders Skar

Hi!

I'm trying to setup a servlet to handle all request that does not map
to a file on the webserver. I've set up a error-page in web.xml that
points to my servlet. I want my servlet to lookup the requested URL
in a database.

The only problem is that when the servlet is called, I want to get the
original URL requested by the user, not the URL of my 404 servlet.

Does anyone know how to do this?

Thanks in advance for any help!

Anders
 
A

Anders Skar

Hi!

I'm trying to setup a servlet to handle all request that does not map
to a file on the webserver. I've set up a error-page in web.xml that
points to my servlet. I want my servlet to lookup the requested URL
in a database.

The only problem is that when the servlet is called, I want to get the
original URL requested by the user, not the URL of my 404 servlet.

Found the solution myself:

request.getAttribute("javax.servlet.error.request_uri")

Anders
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top