• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Problem with session handling using custom tags

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Thanks for bothering to read this. I'm trying to tidy up some JSPs which had scriptlets all over them, by building the functionality into custom tags. The problem I'm seeing is that calls to
request.getSession(false)
return different HTTPSession objects, even though the HTTPServletRequest object is the same one (at least according to the ID tag in my debugger).
Here's the relevant fragment of the JSP:

Here's the code from the <shriek:connect /> tag. It is intended to get a database connection from the ConnectionFactory & store it in the session.

This seems to work fine.
The next tag, <shriek:restaurantListByLocale>, tries to use that Connection from the session. Here's the code from that tag handler:

printSessionAttributes() just dumps all of the session's attributes onto the console.
What happens is that the HTTPSession object returned in the doStartTag() method is a different one to the one returned in the doInitBody() method, and so the JSPException with the message "Connection not found in session" is thrown.
Can anyone shed some light on this? And perhaps recommend a good book on custom tags - all my books are very light on details.
Many many thanks
Dave
[ April 15, 2003: Message edited by: Dave Mulligan ]
 
Dave Mulligan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I've figured it out.
I'd missed the <%@ page session="true" %> tag from the top of the page. Doh! :roll:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic