Hi.. Instead of using encodeURL use encodeRedirectURL of the httpservletresponse object. That will even support the encoding of url with or without the browser's cookies support. Just read this.... public java.lang.String encodeRedirectURL(java.lang.String url) Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. Because the rules for making this determination can differ from those used to decide whether to encode a normal link, this method is seperate from the encodeURL method. All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.
------------------ Narasimha Reddy --------------- Sun certified Enterprise architect(Part-I) Sun Certified Web Component Developer IBM Certified in OOAD with UML IBM Certified in enterprise connectivity test Oracle Certified in SQL and PL/SQL. Sun Certified Java2 Programmer
Adam: check the API carefully. There are two methods, encodeURL and encodeUrl, the former being the one to use, and the later being deprecated.
narasimha: the original poster is not using the URL to redirect a response, only to output the link to the output stream.
Both methods (encodeRedirectURL and encodeURL) will support the encoding urls when the browser doesn't offer cookie support.
Adam's idea is probably accurate, that the browser probably has cookies enabled, so encodeURL doesn't appear to do anything.
malhar, if you use Tomcat, there is a post already here at javaranch that talks about how to force Tomcat to use URL re-writing, no matter what the browser uses (cookies or no). That way, you could test the encodeURL without having to affect your browser settings. Other servlet containers might have similar functionality. http://jakarta.apache.org/tomcat/tomcat-4.0-doc/config/context.html (search this page for 'cookies')
Originally posted by Mike Curwen: malhar, if you use Tomcat, there is a post already here at javaranch that talks about how to force Tomcat to use URL re-writing, no matter what the browser uses (cookies or no). That way, you could test the encodeURL without having to affect your browser settings. Other servlet containers might have similar functionality. http://jakarta.apache.org/tomcat/tomcat-4.0-doc/config/context.html (search this page for 'cookies')
sorry dear i m not using TOMCAT, but then how wud i resolve the prob, i.e to encode the URL with the session id..?? tia malhar
Hi, another reason may be that your getSession() method returns an existing session and that the the session id is from Cookie. Check with call to req.isRequestedSessionIdFromCookie().