• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Issue with encodeURL.

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

I am facing an issue while using response.encodeURL(),

I am using the following statement to add jsessionid to my URL (cookies disabled on the browser).

out.println("<a href=\""+ response.encodeURL("/checkcookie.do") +"\">click here</a>");

from my doPost() method.

as given in HFSJ Page 236.

When I place my cursor over the "click here" link which appears, I see the following link in the status bar.

http://localhost:8080/checkcookie.do

and the container is not able to find a matching entry in the web.xml

However, when I replace the statement with the following, the container is able to find the correct servlet and invoke it.

out.println("<a href=."+ response.encodeURL("/checkcookie.do") + ">click here</a>");

The link for the "click here" text, in this case is

http://localhost:8080/CookieApp/checkcookie.do

But, there is one more issue. In the CheckCookie servlet when I do a request.getSession() and invoke the isNew() method on the session object, I get a TRUE instead of FALSE.

Please check this and let me know what I am doing wrong.

Thanks in advance for your support.
Regards,
Sanjeev
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

But, there is one more issue. In the CheckCookie servlet when I do a request.getSession() and invoke the isNew() method on the session object, I get a TRUE instead of FALSE.



Try :

http://127.0.0.1:8080/CookieApp/checkcookie.do



However, when I replace the statement with the following, the container is able to find the correct servlet and invoke it.

out.println("<a href=."+ response.encodeURL("/checkcookie.do") + ">click here</a>");

The link for the "click here" text, in this case is

http://localhost:8080/CookieApp/checkcookie.do




I think <a href="+ response.encodeURL("checkcookie.do") + "> should also work. Reason being / means home of web container context. So first statement was giving error. However second url becomes ./checkcookie.do, and . means current directory.


Please correct me if I am wrong?
 
Sanjeev BhimaRao
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Arvind. Let me check this and get back to you.

Regards
Sanjeev
 
Sanjeev BhimaRao
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That helps. Thanks a lot Arvind Removing the "/" worked for me.

Regards
Sanjeev
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic