Reputation: 2943
I'm trying to add the session tracking feature to a 12 year old java web application. Which uses MVC pattern with jsp and servlets. We need to make it work if cookies are disabled.
I like to know what is the best way to implement session tracking to this application? :)
and when i use getRequestDispatcher, do i need to use encodeURL ? like this ?
getRequestDispatcher(res.encodeURL(jspname));
Thanks...
Upvotes: 2
Views: 649
Reputation: 403581
You need to go through the application looking for places where it generates internal links, and pass those links through the HttpServletResponse.encodeUrl()
method. This will rewrite the URL if the application thinks it's necessary, such as when it's detected that cookies are not being supported by the client.
Given the age of the application, you may have to do this the hard way, i.e. using JSP expressions like:
<a href="<% response.encodeUrl("/link") %>">
If JSTL is an option, then the <c:url>
makes url rewriting a little bit easier.
Upvotes: 4