This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, Whenever we are dealing with Connection in JSP, can we put the connection in the session and use it through the session.. like: Connection conn=DriverManager.getConnection(url,user,password); session.putValue("conn",conn); And in another page: Connection conn=(Connection)session.getValue("conn"); So we need to create another connection rite.. Just taking it from session.. Is it recommended insteadof Connection Pooling.. Thanks in advance.. Pranit..
Originally posted by Pranit Saha: Whenever we are dealing with Connection in JSP
Stop right there. You shouldn't be dealing directly with a Connection in a JSP. Even forgetting about maintainability issues, it's very hard to get right and not end up with connection or statement leaks if, for example, an impatient user presses STOP or REFRESH on the browser. Instead of this, consider using an MVC (Model II) architecture where the hard work is being done by controller command objects (action objects for Struts aficionados) and the JSPs merely render the results.
can we put the connection in the session and use it through the session..
First, this would consume one connection per user, something you can only afford in very low traffic situations. Second, session-scoped objects may be accessed by multiple threads simultaneously and Connection objects do not always take kindly to that, even disregarding that it would wreak havoc with any transactional stuff you might be doing.
Is it recommended insteadof Connection Pooling..
No. (You saw that one coming, right? ) - Peter [ April 22, 2002: Message edited by: Peter den Haan ]
Joined: Sep 09, 2001
Hi, Thanks a lot for your reply.. It has helped me a lot.. Pranit..