• Post Reply Bookmark Topic Watch Topic
  • New Topic

saving to the ServletContext.......  RSS feed

 
peter piper
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am currently building a web app using tomcat and the MVC design pattern - controllerservlet, beans and jsp's.

I get a connection to the database in my init method in the servlet and then I would like to save it to the servlet context for access by my beans (that do the actual sql queries).
However, I cannot seem to get it to work. I am using getServletContext().setAttribute("connection",conn); to try to save it to the context.
I know my connection code works, and I know my beans work. But when I put it all together I cannot save the connection to the Context. This will be much more efficent than getting every bean to connect/disconnect each time. And there is no need to a ConnectionPool as the system will be used only once a day by one person.
Am I going about it the right way ?? I cannot think of another way to approach it........
thanks in advance Chris
 
peter piper
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whoops this was meant for the serlvets forum - I have reposted there !
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!