wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Confirmation  required Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Confirmation  required" Watch "Confirmation  required" New topic
Author

Confirmation required

Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
if we have to encode redirect that doest not support cookies then below methods should be used.
response.encodeRedirectURL(response.redirect("url"));
Thanks
Sreeraj G Harilal
Ranch Hand

Joined: Apr 19, 2006
Posts: 310
response.redirect("url")


SCJP 5.0<br />SCWCD 1.4<br />Preparing for <b>SCEA</b>.<br /><b>"I prefer an interesting vice to a virtue that bores."</b>
Marcus Green
arch rival
Rancher

Joined: Sep 14, 1999
Posts: 2813
Was that a question or a statement?


SCWCD: Online Course, 50,000+ words and 200+ questions
http://www.examulator.com/moodle/course/view.php?id=5&topic=all
Siddharth Purandare
Ranch Hand

Joined: Nov 13, 2006
Posts: 101
Hi Gowher,

I will try my best to explain let me know whether you get it.

As per Head First URL re-writing is automatic ONLY if you encode your URL's through the 2 method of response object i.e
1. encodeURL(java.lang.String url) and
2. encodeRedirectURL(java.lang.String url)

rest of the things container will take care by itself. NOW the question is when to use which method??

the method encodeRedirectURL(java.lang.String url)
is used if:

All URLs sent to the HttpServletResponse.sendRedirect method should be run through encodeRedirectURL(java.lang.String url)

Next Doubt may come like what is sendRedirect so from the Java API here is the extract.

sendRedirect
public void sendRedirect(java.lang.String location)
throws java.io.IOExceptionSends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container must convert the relative URL to an absolute URL before sending the response to the client. If the location is relative without a leading '/' the container interprets it as relative to the current request URI. If the location is relative with a leading '/' the container interprets it as relative to the servlet container root.
If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.

Parameters:
location - the redirect location URL
Throws:
java.io.IOException - If an input or output exception occurs
java.lang.IllegalStateException - If the response was committed


Hope you have understood.


So the final conclusion is YOU CANNOT USE response.encodeRedirectURL(response.redirect("url")); what you mentioned in the question!!!


Siddharth Purandare<br />SCJP 1.4 - 76%<br />SCWCD 1.4 - 85%<br /> <br />It is the "attitude" and not the "aptitude" which determines "altitude".
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
HFS&JSP pno-237 says
URL rewriting is automatic but only if you encode your URLs.You have to run all your URLs through a method ot the response object-encodeURL() or encodeRedirectURL()and the container does everything else.
I thing meaning of above statement is

encodeURL("url");
response.encodeRedirectURL(response.redirect("url"));

is it so?
Siddharth Purandare
Ranch Hand

Joined: Nov 13, 2006
Posts: 101
No Gowher the correct USAGE is

response.sendRedirect(response.encodeRedirectURL("/whateveryouwish.jsp"));

because response.encodeRedirectURL("/whateveryouwish.jsp") will return a String and sendRedirect() method accepts String signatures of the 2 methods are as below:

1. public void sendRedirect(java.lang.String location)
throws java.io.IOException

2. public java.lang.String encodeRedirectURL(java.lang.String url)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Confirmation required