views:

140

answers:

1

Hello,

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...

+3  A: 

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.

skaffman
Do I need to modify the form's action?So in short i need to modify all links in jsp and servlets.
coder247
@coder247: Yes, form actions, links, and redirects all need encoding.
skaffman
@skaffman: Is there any tomcat configurations available for URL rewriting?
coder247
There are several settings related to URL rewriting, but there's nothing which edits the code for you. That's developer's (your) job.
BalusC