Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!