| Author |
encodeURL methods
|
emmanuel ramos
Greenhorn
Joined: Dec 21, 2011
Posts: 13
|
|
hi All
I have a question about the encodeURL and encodeRedirectURL, what is the diference between them and why if I put
<a href="<% response.encodeURL("sessions.jsp"); %>">link</a>
why this link points to another direction that is not the JSP
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56229
|
|
I don't really know what you mean by that, but you shouldn't be using scriptlets in a JSP at all. You should be using the JSTL's <c:url> tag to create properly encoded URLs.
Please read this this JspFaq entry.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
emmanuel ramos
Greenhorn
Joined: Dec 21, 2011
Posts: 13
|
|
Bear Bibeault wrote:I don't really know what you mean by that, but you shouldn't be using scriptlets in a JSP at all. You should be using the JSTL's <c:url> tag to create properly encoded URLs.
Please read this this JspFaq entry.
I'am reading the book "Head Firts in Servlets and JSP" and the book put this code
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException {
response.setContentType(“text/html”);
PrintWriter out = response.getWriter();
HttpSession session = request.getSession();
out.println(“<html><body>”);
out.println(“click me”);
out.println(“</body></html>”);
}
and Say " if you
don’t explicitly encode your URLs, and the client won’t accept cookies,
you don’t get to use sessions. If you do encode your URLs, the Container
will first attempt to use cookies for session management, and fall back to URL
rewriting only if the cookie approach fails."
My question is what is the diference between response.encodeURL() and encodeRedirectURL(), because in the book are very similar this methods?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56229
|
|
|
Have you checked the javadoc?
|
 |
Vishal Shaw
Ranch Hand
Joined: Aug 09, 2012
Posts: 179
|
|
Hi,
Please check out this link
Regards,
Vishal
|
Programming is about thinking, NOT coding
|
 |
emmanuel ramos
Greenhorn
Joined: Dec 21, 2011
Posts: 13
|
|
thank you very much is what I wanted
Vishal Shaw wrote:Hi,
Please check out this link
Regards,
Vishal
|
 |
Ankush Kaundal
Ranch Hand
Joined: May 12, 2011
Posts: 30
|
|
response.encodeURL("somevalue") -> here encodeURL will add extra session ID info to the end of the URL.
but if you want to redirect to some other URL and still want to maintain session then use response.encodeRedirectURL("somevalue").
|
 |
 |
|
|
subject: encodeURL methods
|
|
|