• 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Problem in reading cookies  RSS feed

Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am facing an strange problem.There are one java application with struts.
it is working fine.
there was one modification in this application that we need to change this application to read user id by cookies.
So in login action class i read the cookie and set to formbean property.
but when next time in any action it is going to read data from it is comming null.
i simply do
1-read cookie value which is userid suppose it is coming 00116084
now i set this value to userid frombean propert by form.setUserId(00116084)
now when
user call login method
i simply read userid from bean and call db method. and set value in session as it was
till here every thing is fine.
now when i read userid from session in any other class it gives error null in seesion.
so it is happning .the proble only when i read user id from cookie and set it to formbean.
please help this is urgent

Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi pandey,

There is no need to set the userid to the fombean object and then store it in the session. you can directly store it in the session.Like,

You can do as in above. In your scenario, check the form bean scope. i mean whether it is request (or) session scope. If it is request , what happens is for every request prior to populate() , reset() is called. which clears previous values.
amitabh pandey
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi vipul
thanks for reply

my first question if i set directly into the seesion as you tell then will problemget resolved means this was the problem.
or after thuis i need to check another thing as scope.

but why it reset when i comes by cookies
means when i access normaly then it is ok.

and please tellme how i resolve this problem

All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!