开发者

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

开发者 https://www.devze.com 2023-01-15 11:50 出处:网络
In our JSP pages, we useextensively.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 Htt

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

精彩评论

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