This week's book giveaway is in the Web Services forum.
We're giving away four copies of Microservices in Action and have Morgan Bruce & Paulo A. Pereira on-line!
See this thread for details.
Win a copy of Microservices in Action this week in the Web Services forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Issue with encodeURL.  RSS feed

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
That helps. Thanks a lot Arvind Removing the "/" worked for me.

Regards
Sanjeev
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!