Hi everyone.
I cannot figure out what the difference between these 2 methods (response.encodeURL() and response.encodeRedirectURL). The Servlet API says that the encodeRedirectURL must ALWAYS be used within response.sendRedirect() commands. The reason it gives is as follows:
"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."
Can someone please explain what this really means? How do the rules differ for a redirect link?
Thanks
Paddy.
-
encodeURL vs encodeRedirectURL (6 messages)
- Posted by: Paddy Murphy
- Posted on: April 25 2001 15:07 EDT
Threaded Messages (6)
- encodeURL vs encodeRedirectURL by Paddy Murphy on April 25 2001 15:21 EDT
- encodeURL vs encodeRedirectURL by Sankara Subramanian Palanisamy on May 08 2001 06:30 EDT
- encodeURL vs encodeRedirectURL by Paddy Murphy on May 09 2001 01:42 EDT
- encodeURL vs encodeRedirectURL by Sankara Subramanian Palanisamy on May 08 2001 06:30 EDT
- encodeURL vs encodeRedirectURL by Kapil Israni on April 25 2001 16:03 EDT
- encodeURL vs encodeRedirectURL by Paddy Murphy on April 26 2001 08:39 EDT
- encodeURL vs encodeRedirectURL by atul kumar on July 26 2004 02:32 EDT
-
encodeURL vs encodeRedirectURL[ Go to top ]
- Posted by: Paddy Murphy
- Posted on: April 25 2001 15:21 EDT
- in response to Paddy Murphy
sorry - my previous quote from the Sun Servlet API regarding the need for response.encodeRedirectURL() should hve read as follows:
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. -
encodeURL vs encodeRedirectURL[ Go to top ]
- Posted by: Sankara Subramanian Palanisamy
- Posted on: May 08 2001 06:30 EDT
- in response to Paddy Murphy
Hi,
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 encoding session ids with URL but only while redirecting.
sankar. -
encodeURL vs encodeRedirectURL[ Go to top ]
- Posted by: Paddy Murphy
- Posted on: May 09 2001 13:42 EDT
- in response to Sankara Subramanian Palanisamy
HiSankar.
I agree with what you're saying, but you havene't explained the reasoning behind the need to ALWAYS use encodeRedirectURL() in a SendRedirect(), whereas we can use encodeURL() otherwise.
Do you understand my question?
Thanks
Paddy -
encodeURL vs encodeRedirectURL[ Go to top ]
- Posted by: Kapil Israni
- Posted on: April 25 2001 16:03 EDT
- in response to Paddy Murphy
both these methods revolve around the concept of URL rewriting. i dont know whether u r aware bout this. but basically it involves suffixing the URL with a HTTP_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 dependent on browser configuration, thus not reliable at all. now Session is a comprehensive topic on its own, so wont discuss it now.
but yes the difference between the methods is in their usage and not their fuctionality. both perform the same task of re-writing a URL.
us use encodeRedirectURL when u send a redirect header to the browser using response.sendRedirect(string URL)
for eg lets say on a partucular condition u want to redirect to different page
if (name == null){
response.sendRedirect(response(encodeRedirectURL("errorPage.jsp"))
}
on the other hand lets say u wanna 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. -
encodeURL vs encodeRedirectURL[ Go to top ]
- Posted by: Paddy Murphy
- Posted on: April 26 2001 08:39 EDT
- in response to Kapil Israni
Hi Kapil
Thanks for that - I understand the purpose of URL rewriting - but I'm still questioning why we have 2 seperate methods, and Sun's statement that the encodeRedirectURL() method does something different to the encodeURL() method.
Paddy -
encodeURL vs encodeRedirectURL[ Go to top ]
- Posted by: atul kumar
- Posted on: July 26 2004 02:32 EDT
- in response to Paddy Murphy
Hi,
As far as i know encodeURL and encodeRedirectURL having diffrent feature.
Just have a look at this.
The encodeURL() method do more than just embed the session ID into the URL.
1)It also rewrites URLs relative to the current document.if the url is not starting with http//.
2)encodes any parameters added with the request.addQueryParameter or request.addURLParameter methods.
Whereas encodeRedirectURL only encode the session ID associated with the realtice URL.