aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes encodeURL vs encodeRedirectURL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "encodeURL vs encodeRedirectURL" Watch "encodeURL vs encodeRedirectURL" New topic
Author

encodeURL vs encodeRedirectURL

Srini Admala
Ranch Hand

Joined: Dec 04, 2001
Posts: 50
What's the difference between HttpServletResponse.encodeURL(String url) & HttpServletResponse.encodeRedirectURL(String url) ?
Both say
"The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL".
what does "rules for making this determination" mean in teh following API doc for encodeRedirectURL ?
"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. "
Any ideas ?
-Srini
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Srini:
The decision to be taken by the rules is whether the target page (to which the request is being redirected) participates in a session or not. If the target page doesn't participate in a session, then there is no point in rewritting the URL with session info. IMO, thisis the rule.
Whereas if you use encodeURL(...) method, it will rewrite the URL based on whether the client has enabled or disabled Cookies.
So in a way, the rules for encodeURL(...) method are determined by the client you are talking to. On the other hand, with the encodeRedirectURL(...) method, the rules are determined by both the server and the client.
Anyother views/explanations....
- satya
ps (response to another thread):
Sorry, I couldn't shut-up...


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Malli Raman
Ranch Hand

Joined: Nov 07, 2001
Posts: 312
Originally posted by Madhav Lakkapragada:
[QB]Srini:
The decision to be taken by the rules is whether the target page (to which the request is being redirected) participates in a session or not. If the target page doesn't participate in a session, then there is no point in rewritting the URL with session info. IMO, thisis the rule.

Hi friends,
As I am not clear about what madhav has mentioned here & difference between encodeURL and encodeRedirectURL, So I am posting this here.
In this Madav told that based on session participation we have to call to either encodeURL and encodeRedirectURL. In this he is not mentioned which method is to be called for a url which is not going to be paritcipate in the session and which method has to be called for participating in the session.

<----
Whereas if you use encodeURL(...) method, it will rewrite the URL based on whether the client has enabled or disabled Cookies.
So in a way, the rules for encodeURL(...) method are determined by the client you are talking to. On the other hand, with the encodeRedirectURL(...) method, the rules are determined by both the server and the client.
---->
I am not sure about the above points. Because I heard if cookies are disabled then URLRewriting will be enabled in most of the servers for session tracking by default (I think weblogic behaves like that). Can anyone please explain me detaily.
Thanks & Regards,
M.S.Raman
Ryan Wilson
Ranch Hand

Joined: Apr 16, 2003
Posts: 65
Malli
I'm not sure if most servers will perform the function of using URL rewriting if cookies are disabled. I think the more important questions to ask is if J2EE 1.3 specification require server to perform URL rewriting when cookies are disabled. After all we are being tested on the J2EE spec and not the extra functions of most servers. Please correct me if I'm wrong
about this point.
Thank You
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
I'm not sure if most servers will perform the function of using URL rewriting if cookies are disabled
Some web application frameworks (struts) do the encoding for you.
the more important questions to ask is if J2EE 1.3 specification require server to perform URL rewriting when cookies are disabled.
nope.


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: encodeURL vs encodeRedirectURL