• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cookie not being sent back to browser

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure if the Struts forum is the appropriate folder for this, so since I think the problem is is happening in my DAO class, I'll post it here. I'm trying to create a poll where the user sees it in the JSP if he hasn't voted. Once he does vote, his vote is processed and a cookie is sent back to tell the JSP to show the results rather than the ballot. The tag that is supposed to read the cookie is returning a NullPointerException, which I've traced to the line HttpSession currentSession = (HttpSession) request.getSession();. Here is my DAO's code so you can see everything in context. Any help out there?

 
Frank Serkland
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I resolved the NullPointerException by adding this line.



However, the cookie still isn't being sent back to the browser? Can anyone help me with this, or is this a question for another forum?
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe you're supposed to set the cookie in the response object; not the session object.
 
Frank Serkland
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tom Reilly wrote:I believe you're supposed to set the cookie in the response object; not the session object.



It had to be something simple like that, didn't it? Thank you, Tom. Your suggestion is the one that worked.
reply
    Bookmark Topic Watch Topic
  • New Topic