Labels
- Apache (10)
- Articles (4)
- BPM Tools (5)
- Glassfish (16)
- Hadoop (10)
- HP ALM (6)
- HP SOA Systinet (14)
- Issues (19)
- JAVA (85)
- JBoss (16)
- jQuery (4)
- Load Runner (37)
- Quality Center (49)
- Testing (24)
- Tips and Tricks (16)
- Tomcat (4)
- Usefull Links (18)
- Weblogic (41)
- WebSphere (2)
Monday, June 11, 2012
encodeURL vs. encodeRedirectURL in Java?
Both these methods revolve around the concept of URL rewriting. I don’t know whether u r aware bout this. But basically it involves suffixing the URL with aHTTP_QUERY_STRING, which mostly is a session id used to keep track of a particular users context. URL re-writing is used get over the usage of cookies which are dependenton browser configuration, thus not reliable at all. Now Session is a comprehensive topicon its own, so won’t discuss it now.But yes the difference between the methods is in their usage and not their functionality.Both perform the same task of re-writing a URL.us use encodeRedirectURL when u send a redirect header to the browser usingresponse.sendRedirect(string URL)for e.g. lets say on a particular condition u want to redirect to different pageif (name == null){response.sendRedirect(response(encodeRedirectURL("errorPage.jsp"))}on the other hand lets say u want to provide a link to shopping cart page to a user - printWriter.println("A HREF=" + response.encodeURL("shoppingCart.jasp") + ">")thus essentially they do same thing of re-writing the URL for non-cookie compliant browser.In short.....encodeURL is used for all URLs in a servlet's output.It helps session ids to be encoded with the URL.encodeRedirectURL () is used with res.sendRedirect only. It is also used for encodingsession ids with URL but only while redirecting.
Labels:
JAVA
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment