This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes Release resources Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Java » Servlets
Bookmark "Release resources" Watch "Release resources" New topic
Author

Release resources

Vicky Jain
Ranch Hand

Joined: Aug 02, 2003
Posts: 52
Hello guys,

I'm having the following two questions regarding timeouts:

1) How can i release the acquired resources like database connection, handles to other resources etc, when the servelet timeouts.

2) Also how can i change the session-timeouts?

ThanQ


SCJP1.4(96%)<br />A drop of ink can make millions think.
Juanjo Bazan
Ranch Hand

Joined: Feb 04, 2002
Posts: 231
1) How can i release the acquired resources like database connection, handles to other resources etc, when the servelet timeouts.


You can associate a HttpSessionListener. This class is in the javax.servlet.http package and it has a method sessionDestroyed.

2) Also how can i change the session-timeouts?


Do it in your deployment descriptor file:
add this to your web.xml to set the session timeout to 30 minutes:



HTH
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31549
    
184

Vicky,
Beware of holding a connection for the entire life of the session. A connection is a very expensive resource.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Vicky Jain
Ranch Hand

Joined: Aug 02, 2003
Posts: 52
Thanks to all of you guys out here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Release resources