Re: Servlets Sharing Resources

2009-04-21 Thread Paul Libbrecht
Various servlets or various webapps? Various servlets is trivial, indeed using ServletContext.getAttribute(). Various webapps is more difficult: - you need to set cross context so that context.getContext("/ otherpath") is accessible (a config of context in tomcat) - you need classes to be shared

RE: Servlets Sharing Resources

2009-04-21 Thread David Seltzer
can think of is that I need to make sure that one servlet is responsible for setting it up and disposing of it. -Dave -Original Message- From: patrick o'leary [mailto:pj...@pjaol.com] Sent: Tuesday, April 21, 2009 1:16 PM To: java-user@lucene.apache.org Subject: Re: Servlets Sharing R

Re: Servlets Sharing Resources

2009-04-21 Thread patrick o'leary
everything hit the same > doGet(). > > -Original Message- > From: patrick o'leary [mailto:pj...@pjaol.com] > Sent: Tuesday, April 21, 2009 12:51 PM > To: java-user@lucene.apache.org > Subject: Re: Servlets Sharing Resources > > Why not have 1 servlet and base

RE: Servlets Sharing Resources

2009-04-21 Thread David Seltzer
l.com] Sent: Tuesday, April 21, 2009 12:51 PM To: java-user@lucene.apache.org Subject: Re: Servlets Sharing Resources Why not have 1 servlet and based on a parameter / url, serve 2 different outputs? if(request.getString("asXML") !=null) showXML(); else showOtherStuff(); Save yoursel

Re: Servlets Sharing Resources

2009-04-21 Thread patrick o'leary
Why not have 1 servlet and based on a parameter / url, serve 2 different outputs? if(request.getString("asXML") !=null) showXML(); else showOtherStuff(); Save yourself the hassle of dealing with jndi / contexts / spring or SingleTons On Tue, Apr 21, 2009 at 12:01 PM, David Seltzer wrote:

Re: Servlets Sharing Resources

2009-04-21 Thread Mindaugas Žakšauskas
Hi, Generally speaking, yes - this is the most straightforward way of storing application-bound data. Somewhat related explanation available here: http://www.coderanch.com/t/358143/Servlets/java/servlet-context-vs-session Regards, Mindaugas On Tue, Apr 21, 2009 at 5:23 PM, David Seltzer wrote:

Re: Servlets Sharing Resources

2009-04-21 Thread mark harwood
, 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

RE: Servlets Sharing Resources

2009-04-21 Thread David Seltzer
: Mindaugas Žakšauskas [mailto:min...@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 pro

Re: Servlets Sharing Resources

2009-04-21 Thread Mindaugas Žakšauskas
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 c

Servlets Sharing Resources

2009-04-21 Thread David Seltzer
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 XM