Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Issue with encodeURL.

 
Sanjeev BhimaRao
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
 
Arvind Giri
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