Win a 3 month subscription to Marco Behler Videos this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Cookie Problem  RSS feed

 
Debajyoti Kundu
Ranch Hand
Posts: 32
1
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,
I need some help in Cookie. I have created a servlet, where i need to create a cookie which will hold value some of user id which is given in a login page. Code of the login page is not available, only url is known. Along this url a return url is added. After successful validation servlet will redirect to that return url. This login page is invoked from my servlet only.

Can any one suggest a way, by which I can capture the required information in side a Cookie.

N.B: I have tried Cookie[] cookie=request.getCookies(); and it's not working.
 
Pete Nelson
Ranch Hand
Posts: 147
Debian Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is anything other than your Serlvet accessing this Cookie? What initially created the Cookie?

If you are looking at a pure-servlet solution, look instead at HttpServletRequest.getSession(boolean). This is a higher-level way to create session-persistent data in servlets. The getCookies() method is more low-level, and returns any Cookie data specifically sent from the browser (say if you created a Cookie using JavaScript).
 
Miku Ranjan
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If you want to store your value in client browser then use cookie.
That should work , the work flow is for the first request the client will not have the value in cookie but after that you will have that value in cookie .
 
Debajyoti Kundu
Ranch Hand
Posts: 32
1
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pete, Miku

Thanks for your suggestions. Few days ago I just came to know that value of the cookies were encrypted and the original value can be retrieved after following some formalities.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!