tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tobias Eriksson" <tobias.eriks...@comopt.com>
Subject servlet lifetime question
Date Fri, 20 Aug 2004 12:46:19 GMT
Hi
 I have a servlet creating a bean and then publishing it on a jsp page.
In the logs I can see that the FINALIZER for the servlet and bean is run
after a short while. 
 There are a few things that I don't understand here, but foremost
1) Why is the bean garbage collected when I in the servlet and jsp page
have set the scope to be SESSION? 

mailbox = (MailBean) request.getSession().getAttribute( "mailbox" );
if( mailbox == null ) {
	mailbox = new MailBean( request.getContextPath() );
}
mailbox.populateLocalStore();

request.getSession().setAttribute("mailbox", mailbox);
			
RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher("/inbox.jsp");

dispatcher.forward( request, response );

2) When I press [REFRESH] in the browser, and then look in Tomcat's
stdout-log, I can see that the finalizer for both the servlet and the
bean has been run, but what puzzles me is that I can then see that the
doGet() method of the servlet is run on every REFRESH but then the
servlet does not exists anymore. How is this possible?

InboxServlet constructor running!!!
InboxServlet doGet running!!!
MailBean Constructed...
Parsing POP3 Folder:INBOX Number of messages: 1
InboxServlet finalizer running!!!
MailBean finalizer running...
Adding message with subject: test 4
1 Messages added to the folder; INBOX
found 17 messages in inbox
InboxServlet doGet running!!!

3) Does anyone know of or have a nice mail servlet/jsp solution?

By the way, appreciate all the quick responses I got so far, thanx guys.

Regards
 Tobias


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message