• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

encodeURL methods

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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



 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
emmanuel ramos
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you checked the javadoc?
 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Please check out this link

Regards,
Vishal
 
emmanuel ramos
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you very much is what I wanted



Vishal Shaw wrote:Hi,

Please check out this link

Regards,
Vishal

 
Ranch Hand
Posts: 36
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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").
 
If you like strawberry rhubarb pie, try blueberry rhubarb (bluebarb) pie. And try this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic