Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with session handling using custom tags  RSS feed

 
Dave Mulligan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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
  • 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:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!