• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet Context for javabean  RSS feed

Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been using a session bean to access my database. I pass the servlet context to the bean and this allows the bean to get the database connection pool attribute from the context.
On my local machine, this servlet context never changes and my site works okay. However, on my uploaded site, the servlet context seems to change. I think this is causing the bean to create a new session.
The results is this. If I run with session scope, my session id changes almost with every request. If I run the bean with request scope, it works fine and my session times out as expected from the web.xml file.
Obviously I would rather not run database queries for every page when once-a-session is enough.
Is there a way that the bean can access the servlet context directly without it being passed?
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!