Hans Sausage Hans Sausage - 1 year ago 77
Java Question

ServletRequest get name of actual page

I am using a

and the
-Function. I would like to know which site is being requested. Some function giving me something like
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 :-(


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