You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mihai Caraman <ca...@gmail.com> on 2011/07/22 18:17:05 UTC

WebListener as jar

Hello,

First of all, I'm new to tomcat and somewhat to java, but I got a question
that I couldn't find answer to it.

So, I'm currently running my war on tomcat7/Servlet3/jdk1.6.
My war basically has (among plain classes) a Servlet for requests and a
WebListener (ServletContextListener) for continuous processing  .

My question is: How can I change the class that now is a WebListener to
start at a given command, not when Tomcat starts.

I looked around at how to start a class in a war like in a jar (setting
manifest for corresponding main class), but with no success.

The final behavior that I'm looking for is to have a servlet that is ran by
tomcat, but at the same time, have access to static objects in the class
that is now used as a Listener. This is needed for repetitive testing
without having to wait for the server redeploying.
*
If this has nothing to do with tomcat and the answer is not of general
interest for this mailing list, please reply privately to my email address,
directing me to an appropriate forum/mailing list.*

Thank you ever so much!
Mihai

Re: WebListener as jar

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/7/22 Mihai Caraman <ca...@gmail.com>:

> The final behavior that I'm looking for is to have a servlet that is ran by
> tomcat, but at the same time, have access to static objects in the class
> that is now used as a Listener. This is needed for repetitive testing
> without having to wait for the server redeploying.

I do not get you - how do you plan to survive deployment?

To share an object between a listener and a servlet in the same webapp
the usual way is to use ServletContext.setAttribute().

Best regards,
Konstantin Kolinko

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