Sorry, I haven't been listening to this thread but can't you just pass the context as a parameter to the method?
Andy > -----Original Message----- > From: Christian J. Dechery [mailto:[EMAIL PROTECTED]] > Sent: 10 July 2002 17:27 > To: [EMAIL PROTECTED] > Subject: Re: Need Ideas... big problem! (long) > > > I'm having some difficulty understanding the solution u guys > provided me... maybe I explained my problem badly, so u aren't > fully understanding it... > > but I have a question that is quite simple: > Is it possible for a class (or Servlet) located in > $tomcat_home\common\classes - that will be accessed from all > webapps - to know from which context a JSP/Servlet called it? > > for example... I have a class A in common\classes and it has a > method doSomething()... say I have a JSP > $tomcat_home\webapps\test\1.jsp that looks something like: > > <%@page import="A"%> > <% > String x = A.doSomething(); > %> > > so... would it be possible for A to know that when doSomething() > was called, the context was "test"? > > > .:| Christian J. Dechery > .:| FINEP - Depto. de Sistemas > .:| [EMAIL PROTECTED] > .:| (21) 2555-0332 > > >>> [EMAIL PROTECTED] 10/07/02 12:12 >>> > A JSP is a servlet, so you shouldn't need to create another class derived > from servlet to do the job. > > If your call is directly to a servlet, that servlet can use the code for > parameter lookup itself as is. > > Regards. > ----- Original Message ----- > From: "Christian J. Dechery" < [EMAIL PROTECTED] > > To: < [EMAIL PROTECTED] > > Sent: Wednesday, July 10, 2002 2:33 PM > Subject: Re: Need Ideas... big problem! (long) > > > didn't work... I did a test here to see if this thing worked before > implementing the Connection Dispatcher... > the Servlet can't find the context in which the JSP that called it is... > > here's what I did: > > * created two classes TesteDispatcher and TesteCallDispatcher. > TesteDispatcher is the Servlet, and TesteCallDispatcher is just a dummy > class to make a call to this servlet... > > * I then placed both classes in $tomcat_home\common\classes > > * created a context called \teste1 > <Context path="/teste1" docBase="teste1" debug="0" reloadable="true"> > <Parameter name="url" value="URL do Contexto teste1" override="false"/> > </Context> > > * created a JSP called teste.jsp > <%@page import="dispatch.TesteCallDispatcher"%> > > <% > TesteCallDispatcher tcd = new TesteCallDispatcher(); > out.println("A URL para esse contexto � \""+tcd.myContextURL()+"\"."); > %> > > when I execute it, nothing happens... there is a call in TesteDispatcher > like this: > ServletConfig sConf = getServletConfig(); <-- this is returning NULL > > what did I do wrong? Or was it that I missunderstood ur solution, > or even, u > missunderstood my problem. :) > > thanks > > > .:| Christian J. Dechery > .:| FINEP - Depto. de Sistemas > .:| [EMAIL PROTECTED] > .:| (21) 2555-0332 > > >>> [EMAIL PROTECTED] 09/07/02 17:41 >>> > Or even simpler why not store it as a parameter in the > server.xml. You will > need to add the parameter to each of your contexts in the server.xml as > follows:- > > <Context path="/examples" docBase="examples" ....> > .............. > <Parameter name="db.url" value="jdbc:postgres://localhost/mydb" > override="false"/> > </Context> > > And then in your servlet code you use the following to retrieve it (from > your servlet):- > > getServletContext().getInitParameter("db.url") > > Regards. > ----- Original Message ----- > From: "Christian J. Dechery" < [EMAIL PROTECTED] > > To: < [EMAIL PROTECTED] > > Sent: Tuesday, July 09, 2002 8:47 PM > Subject: RE: Need Ideas... big problem! (long) > > > Sorry... but could u explain this a little furhter? I'm not familiar with > JNDI. > > thanks > > .:| Christian J. Dechery > .:| FINEP - Depto. de Sistemas > .:| [EMAIL PROTECTED] > .:| (21) 2555-0332 > > >>> [EMAIL PROTECTED] 09/07/02 16:41 >>> > Why don't you store the JDBC URL in JNDI and have DAO look it up > dynamically.... > > Bob Kranson > Software Technical Support Analyst > UNIFACE and Optimal Products Technical Support > U.S. Support Center 888-551-0404 > New Calls: [EMAIL PROTECTED] > 31440 Northwestern Hwy, Farmington Hills, MI 48334-2564 > (248)737-7300 x12702 Fax:(248)737-7574 > > > > -----Original Message----- > > From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] > > Sent: Tuesday, July 09, 2002 2:38 PM > > To: [EMAIL PROTECTED] > > Subject: Need Ideas... big problem! (long) > > > > > > I have a huge problem here... and I can't think of a simple > > solution for it, I'm hoping u guys can give some "light". :) > > > > Let me first describe the "environment" here, then the problem. > > > > We have here a webapp called FAP (c:\tomcat\fap). It is > > composed of: /fap/*.jsp (like a hundred of them) > > /fap/WEB-INF/classes/finep (this package finep has a lot of > > subpackages) /fap/WEB-INF/classes/finep/DAO.class <-- here > > the problem resides... /fab/lib/OracleDrivers.jar > > > > the class DAO provides the Connection to an Oracle database... > > > > so far, everything is fine... but here's the thing... this > > webapp gets replicated... the whole dir, because there are > > other instances of this system with small changes, and we > > didn't have the time to create a self-configuring app to > > allow that... so we copy the whole dir and make the necessary > > changes... BUT... the classes never change... only the > > JSPs... AND another thing that may change is the database > > (and of course DAO)... so how it is done? > > > > we have /fap with DAO.class pointing to a specific db URL > > and; we have (for example) /fap2 with a few JSPs changes and > > DAO.class pointing to another URL. > > > > this of course sux! If we wanna change the database of a > > specific webapp we have to re-compile DAO and place it > > there... and if we change a class (any class) we have to > > update it in ALL the contexts... > > > > What I want: > > I would like to place the package "finep" and the > > OracleDrivers in the global context > > (c:\tomcat\common\classes, \lib), so all would be pretty and > > centralized; and create something like a Connection > > Dispatcher (also in the global context) that would receive > > requests from the JSPs and provide a Connection to the > > specific URL based in which context that JSP was when the > > request was made. I don't know if that's possible... I'm just > > guessing... of course I want do this as painless as > > possible... cuz we have like 80 classes and more than 150 JSPs... > > > > to confuse??? My english also sux... sorry! > > > > > > .:| Christian J. Dechery > > .:| FINEP - Depto. de Sistemas > > .:| [EMAIL PROTECTED] > > .:| (21) 2555-0332 > > > > > > > > The contents of this e-mail are intended for the named addressee only. It > contains information that may be confidential. Unless you are the named > addressee or an authorized designee, you may not copy or use it, > or disclose > it to anyone else. If you received it in error please notify us > immediately > and then destroy it. > > > -- > To unsubscribe, e-mail: < mailto:[EMAIL PROTECTED] > For additional commands, e-mail: < mailto:[EMAIL PROTECTED] > -- To unsubscribe, e-mail: < mailto:[EMAIL PROTECTED] > For additional commands, e-mail: < mailto:[EMAIL PROTECTED] > -- To unsubscribe, e-mail: < mailto:[EMAIL PROTECTED] > For additional commands, e-mail: < mailto:[EMAIL PROTECTED] > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
