On 26/07/2012 22:38, Christopher Schultz wrote:
> Chip,
> 
> On 7/26/12 3:19 PM, Chip McVey wrote:
>> In TC7, is there a way to tell Tomcat to never unload a given
>> servlet unless Tomcat itself is being shutdown?  I want a single
>> servlet instance that I can know will exist for the life of the
>> tomcat process without being unloaded & reloaded (unless someone
>> manually instructs Tomcat to do so, of course).
> 
>> Yes, I know I'm "not supposed to do this" and that the servlet
>> spec says a container is allowed to unload a server any time as
>> long as a request is not in process.  I still would like to know if
>> there's some Tomcat specific way to tell TC7 to never unload the
>> servlet. And yes, I realize even if there is such a way that future
>> versions of Tomcat may remove this capability.  :)
> 
> You have said both "servlet" and "server": which did you mean?
> 
> Do you need a particular web application to stay loaded? That's easy:
> simply don't undeploy it.
> 
> Do you need a single (or multiple) servlet(s) to stay loaded all the
> time? That's also easy: I don't believe Tomcat ever actually unloads a
> servlet. (You can easily test this by implementing the destroy()
> method and emitting some kind of log).
> 
> What is it about the servlet that it needs to stay loaded? Servlets
> aren't really supposed to have any state, so unloading and re-loading
> the servlet shouldn't represent anything traumatic to your web
> application.
> 
> If you have to have some kind of data loaded all the time, consider
> moving that data into the ServletContext (aka "application")
> attributes: then the servlet can be unloaded and re-loaded at will and
> the data will persist.

+1

-> ServletContextListener


p

> -chris
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
> 

-- 

[key:62590808]

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to