开发者

applying JSP/JSTL's <c:url> to a path inside a servlet

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 开发者_StackOverflowtype 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜