ServletRequest get name of actual page
10,226
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)
Author by
Admin
Updated on June 04, 2022Comments
-
Admin almost 2 years
I am using a
Filter
and thedoFilter
-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
-
Admin almost 13 yearsperfect. I didn't think about casting. Casting always hurts my soul. But that ways it works. Quite ugly :-)
-
Bozho almost 13 yearsYou will have to get used to casting in servlet filters. Btw, if the answer works for you, you can mark it as accepted (tick below the vote counter)
-
Admin almost 13 yearsStill had to wait 4 min to tick it :-)