views:

73

answers:

1

In our JSP pages, we use extensively. Works great, rewrites the URL to deal with sessionids, contexts, etc. But now we need to do some of this work inside a class that takes an HttpServletRequest and HttpServletResponse as part of the Spring Security specification.

How do I apply a type transformation to a path in a servlet? I guess I could reconstruct the URL with the scheme, host, port, context, path and query parameters (am I missing anything?). But I'd love a standard way to do this so I know it's being done properly.

+1  A: 

The HttpServletResponse#encodeURL() and HttpServletResponse#encodeRedirectURL() deals with sessionids. The context can be obtained by HttpServletRequest#getContextPath().

BalusC
Thanks BalusC. I was aware of the response and request methods to reconstruct the URL, I was just hoping there was a simple standard way like JSTL's <c:url value="/path"/>. This is the route I ended up using though.
at
You're welcome.
BalusC