Hans Sausage Hans Sausage - 1 year ago 73
Java Question

ServletRequest get name of actual page

I am using a

Filter
and the
doFilter
-Function. I would like to know which site is being requested. Some function giving me something like
/firstDirectoryInWebDirectory/lala.jsp
would be perfect.

What is the way to go here? Using the context will be the right way, but I can't find any good method :-(

Thanks

Answer Source

request.getRequestURI() should return the part of the URL after the domain.

From there, you can strip the request.getContextPath()

(You'd have to cast the ServletRequest to HttpServletRequest first)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download