lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mark harwood <markharw...@yahoo.co.uk>
Subject Re: Servlets Sharing Resources
Date Tue, 21 Apr 2009 16:41:04 GMT

Spring is pretty useful for managing and sharing resources - see what looks like a related
example here: http://croarkin.blogspot.com/2008/05/injecting-spring-bean-into-servlet.html


Cheers,
Mark



----- Original Message ----
From: David Seltzer <dseltzer@TVEyes.com>
To: java-user@lucene.apache.org
Sent: Tuesday, 21 April, 2009 17:23:55
Subject: RE: Servlets Sharing Resources

Thanks Minduagas,

So in Tomcat, is there a way to store a variable outside an individual Servlet in the ServletContext?
The API shows ServletContext.setAttribute and ServeletContext.getAttribtue. Would that be
a way to make an object application-bound?

-Dave

-----Original Message-----
From: Mindaugas Žakšauskas [mailto:mindas@gmail.com] 
Sent: Tuesday, April 21, 2009 12:14 PM
To: java-user@lucene.apache.org
Subject: Re: Servlets Sharing Resources

Hi,

Servlets are stateless and they must extend
javax.servlet.http.HttpServlet, therefore I'm afraid the idea of
manager class is probably unrealistic.

The stuff you want to achieve normally works by either placing objects
into the HTTP session (user-bound) or attaching them to your
application context (application-bound).

Regards,
Mindaugas

On Tue, Apr 21, 2009 at 5:01 PM, David Seltzer <dseltzer@tveyes.com> wrote:
> Hi All,
>
> Sorry for the slightly off-topic question, but I've just run into a gap
> in my understanding of Servlet programming.
>
> The question: Is it possible for two servlets to share access to an
> instance of IndexSearcher or an IndexReader? I'm thinking about setting
> up a Search servlet to provide XML search results and a Statistics
> servlet to provide numeric statistics based on the same data.
>
> I imagine the right way to do it is to make both servlets child classes
> of a manager class, but I'm not sure how that would look. I'm also not
> sure how to configure tomcat in this scenario?
>
> -Dave
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

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


      


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


Mime
View raw message