Forums Register Login

diff b/w encodeURL and encodeRedirectURL

+Pie Number of slices to send: Send
hello
what is the difference b/w encode URL and encodeRedirectURL. how do they differ and what exactly is redirection.
+Pie Number of slices to send: Send
Usually session is maintained using cookies, but there may be cases when developer can not rely on the availability of cookies(as cookies can be disabled in browsers). under such circumstances encodeURL() is used. This method first checks whether cookies are enabled on client browser or not. If cookies are disabled, than it appends jsessionid to the url, to uniquely identify the session.
Following is the extract from servlet api docs. http://java.sun.com/products/servlet/2.3/javadoc/
encodeURL
public java.lang.String encodeURL(java.lang.String url)
Encodes the specified URL by including the session ID in it, 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. For example, if the browser supports cookies, or session tracking is turned off, URL encoding is unnecessary.
For robust session tracking, all URLs emitted by a servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.

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.
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 773 times.
Similar Threads
diff b/w threetier and mvc
Diff b/w Dao's and valueobjectpattern?
Difference b/w "session.putValue" and session.setAttribute"?
Sessions and cookies
difference b/w page and pageContext
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 05:47:14.