This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

saving to the ServletContext.......

 
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 !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic