RE: Need Ideas... big problem! (long)
ok... but remember that all the classes will reside in the common\classes dir... So how will the class know which context accessed it? That's what I can't figure out... I tought about config files... but I don't know inside the dispatcher class how to identify the context... or to read the proper config file... .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 09/07/02 17:24 If you don't want to go the JNDI route, you could also do something like set init params in each application's web.xml file with the db connection info or create a .properties file for each application and read in the db connection info from that. HTH, -Jeff Kranson, Bob Bob_Kranson@comp To: 'Tomcat Users List' [EMAIL PROTECTED] uware.com cc: Subject: RE: Need Ideas... big problem! (long) 07/09/02 02:41 PM Please respond to Tomcat Users List 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]
Re: Need Ideas... big problem! (long)
well... first one thing... the class that provides the connection (DAO) is not a Servlet... would I have to make a Servlet (the mentioned Connection Dispatcher) in order for that to work??? .:| 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]
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
RE: Need Ideas... big problem! (long)
Well, the classes themselves wouldn't be used to get the init params or read the db.properties file. You would use a Servlet to do that, and then you would just pass the params (or Connections created from those params - however you're doing things) to the instance of the DAO class you would be using in your application/session/request. HTH, -Jeff Christian J. Dechery To: [EMAIL PROTECTED] christian@fincc: ep.gov.brSubject: RE: Need Ideas... big problem! (long) 07/10/02 07:27 AM Please respond to Tomcat Users List ok... but remember that all the classes will reside in the common\classes dir... So how will the class know which context accessed it? That's what I can't figure out... I tought about config files... but I don't know inside the dispatcher class how to identify the context... or to read the proper config file... .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 09/07/02 17:24 If you don't want to go the JNDI route, you could also do something like set init params in each application's web.xml file with the db connection info or create a .properties file for each application and read in the db connection info from that. HTH, -Jeff Kranson, Bob Bob_Kranson@comp To: 'Tomcat Users List' [EMAIL PROTECTED] uware.com cc: Subject: RE: Need Ideas... big problem! (long) 07/09/02 02:41 PM Please respond to Tomcat Users List 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
Re: Need Ideas... big problem! (long)
You can still do this (by using 4.1.7 at least) by declaring all the resources under global resources with different names and then providing a ResourceLink in each context with the generic name you are using to each the appropriate resource. Regards. - Original Message - From: Christian J. Dechery [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, July 10, 2002 12:57 PM Subject: RE: Need Ideas... big problem! (long) ok... but remember that all the classes will reside in the common\classes dir... So how will the class know which context accessed it? That's what I can't figure out... I tought about config files... but I don't know inside the dispatcher class how to identify the context... or to read the proper config file... .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 09/07/02 17:24 If you don't want to go the JNDI route, you could also do something like set init params in each application's web.xml file with the db connection info or create a .properties file for each application and read in the db connection info from that. HTH, -Jeff Kranson, Bob Bob_Kranson@comp To: 'Tomcat Users List' [EMAIL PROTECTED] uware.com cc: Subject: RE: Need Ideas... big problem! (long) 07/09/02 02:41 PM Please respond to Tomcat Users List 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]
Re: Need Ideas... big problem! (long)
There must me a servlet called somewhere which then hands control over to the helper classes to do the work ? Regards. - Original Message - From: Christian J. Dechery [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, July 10, 2002 1:10 PM Subject: Re: Need Ideas... big problem! (long) well... first one thing... the class that provides the connection (DAO) is not a Servlet... would I have to make a Servlet (the mentioned Connection Dispatcher) in order for that to work??? .:| 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]
Re: Need Ideas... big problem! (long)
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
Re: Need Ideas... big problem! (long)
- Original Message - From: Arshad Mahmood [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, July 10, 2002 4:12 PM Subject: Re: Need Ideas... big problem! (long) 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. Oops!! I meant if your call is directly to a JSP then you can do the parameter lookup as is in a scriptlet. Regards. 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
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
Re: Need Ideas... big problem! (long)
On Wed, 10 Jul 2002, Christian J. Dechery wrote: Date: Wed, 10 Jul 2002 13:27:26 -0300 From: Christian J. Dechery [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] 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? Sure ... that's really easy. You've got at least the following options: * Call request.getContextPath() and you'll get the context path of the web application that is responding to this request. * The application object in a JSP page is in fact the ServletContext for the current webapp, so you can call things like % Properties props = new Properties(); InputStream stream = application.getResourceAsStream(/WEB-INF/myprops.properties); props.load(stream); stream.close(); % to load a properties file from inside the WEB-INF subdirectory of your web application. As a general note, however, you should really be doing this sort of thing in startup code of a servlet, which stashes the results as servlet context parameters for everyone else to use. Using scriptlets to mix functional logic into your JSP pages is going to cause you maintenance nightmares over time. Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Need Ideas... big problem! (long)
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
Re: Need Ideas... big problem! (long)
But I want the code I would write in the A class... cuz I will create a Servlet to provide a connection to the JSPs, but I don't wanna change the JSPs... inside my Servlet (A) I don't have access to the request object. Could u write some example code for the A class to figure in which context the method doSomething() was called? Thanks... .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 13:51 On Wed, 10 Jul 2002, Christian J. Dechery wrote: Date: Wed, 10 Jul 2002 13:27:26 -0300 From: Christian J. Dechery [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] 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? Sure ... that's really easy. You've got at least the following options: * Call request.getContextPath() and you'll get the context path of the web application that is responding to this request. * The application object in a JSP page is in fact the ServletContext for the current webapp, so you can call things like % Properties props = new Properties(); InputStream stream = application.getResourceAsStream(/WEB-INF/myprops.properties); props.load(stream); stream.close(); % to load a properties file from inside the WEB-INF subdirectory of your web application. As a general note, however, you should really be doing this sort of thing in startup code of a servlet, which stashes the results as servlet context parameters for everyone else to use. Using scriptlets to mix functional logic into your JSP pages is going to cause you maintenance nightmares over time. Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Need Ideas... big problem! (long)
Say that again? If you have a servlet, it extends HttpServlet, and you most certainly have access to the Request object, as well as the Response object. John Turner [EMAIL PROTECTED] -Original Message- From: Christian J. Dechery [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 10, 2002 1:00 PM To: [EMAIL PROTECTED] Subject: Re: Need Ideas... big problem! (long) But I want the code I would write in the A class... cuz I will create a Servlet to provide a connection to the JSPs, but I don't wanna change the JSPs... inside my Servlet (A) I don't have access to the request object. Could u write some example code for the A class to figure in which context the method doSomething() was called? Thanks... .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 13:51 On Wed, 10 Jul 2002, Christian J. Dechery wrote: Date: Wed, 10 Jul 2002 13:27:26 -0300 From: Christian J. Dechery [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] 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? Sure ... that's really easy. You've got at least the following options: * Call request.getContextPath() and you'll get the context path of the web application that is responding to this request. * The application object in a JSP page is in fact the ServletContext for the current webapp, so you can call things like % Properties props = new Properties(); InputStream stream = application.getResourceAsStream(/WEB-INF/myprops.properties); props.load(stream); stream.close(); % to load a properties file from inside the WEB-INF subdirectory of your web application. As a general note, however, you should really be doing this sort of thing in startup code of a servlet, which stashes the results as servlet context parameters for everyone else to use. Using scriptlets to mix functional logic into your JSP pages is going to cause you maintenance nightmares over time. Craig -- 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]
Re: Need Ideas... big problem! (long)
Hi, Christian. I would recommend now taking a good look at the Java Servlet Specification and letting all these suggestions digest while you go through that. Things should start to make more sense once you have a better handle on servlets. Maybe take a look at the Tomcat servlet examples too. Your servlet should definitely have access to the request object, since if you look at the specs on HttpServlet, you'll see that it is passed as a parameter to its various methods. HTH, -Jeff Christian J. Dechery To: [EMAIL PROTECTED] christian@fincc: ep.gov.brSubject: Re: Need Ideas... big problem! (long) 07/10/02 12:30 PM Please respond to Tomcat Users List But I want the code I would write in the A class... cuz I will create a Servlet to provide a connection to the JSPs, but I don't wanna change the JSPs... inside my Servlet (A) I don't have access to the request object. Could u write some example code for the A class to figure in which context the method doSomething() was called? Thanks... .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 13:51 On Wed, 10 Jul 2002, Christian J. Dechery wrote: Date: Wed, 10 Jul 2002 13:27:26 -0300 From: Christian J. Dechery [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] 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? Sure ... that's really easy. You've got at least the following options: * Call request.getContextPath() and you'll get the context path of the web application that is responding to this request. * The application object in a JSP page is in fact the ServletContext for the current webapp, so you can call things like % Properties props = new Properties(); InputStream stream = application.getResourceAsStream(/WEB-INF/myprops.properties); props.load(stream); stream.close(); % to load a properties file from inside the WEB-INF subdirectory of your web application. As a general note, however, you should really be doing this sort of thing in startup code of a servlet, which stashes the results as servlet context parameters for everyone else to use. Using scriptlets to mix functional logic into your JSP pages is going to cause you maintenance nightmares over time. Craig -- 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]
Re: Need Ideas... big problem! (long)
exaclty... I looked on HttpServlet... request and response are passed as parameters... so I don't HAVE it. And since it's passed as a parameter I would have to change 150 JSPs to pass this new parameter... and I don't wanna change anything, only create a new class... if in the solution comes changing all the JSPs and classes I'm sure that's not the best one... I may have asked the wrong question... let's say: public class TesteDispatcher extends HttpServlet { private static final String CONTENT_TYPE = text/html; //Initialize global variables public void init() throws ServletException { } //Clean up resources public void destroy() { } public String doSomething() { // this is the method... } } Is there anyway doSomething() can know in which Context it was called? Remember that this class is in \common\classes. thanks for ur patience .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 14:23 Hi, Christian. I would recommend now taking a good look at the Java Servlet Specification and letting all these suggestions digest while you go through that. Things should start to make more sense once you have a better handle on servlets. Maybe take a look at the Tomcat servlet examples too. Your servlet should definitely have access to the request object, since if you look at the specs on HttpServlet, you'll see that it is passed as a parameter to its various methods. HTH, -Jeff Christian J. Dechery To: [EMAIL PROTECTED] christian@fin cc: ep.gov.br Subject: Re: Need Ideas... big problem! (long) 07/10/02 12:30 PM Please respond to Tomcat Users List But I want the code I would write in the A class... cuz I will create a Servlet to provide a connection to the JSPs, but I don't wanna change the JSPs... inside my Servlet (A) I don't have access to the request object. Could u write some example code for the A class to figure in which context the method doSomething() was called? Thanks... .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 13:51 On Wed, 10 Jul 2002, Christian J. Dechery wrote: Date: Wed, 10 Jul 2002 13:27:26 -0300 From: Christian J. Dechery [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] 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? Sure ... that's really easy. You've got at least the following options: * Call request.getContextPath() and you'll get the context path of the web application that is responding to this request. * The application object in a JSP page is in fact the ServletContext for the current webapp, so you can call things like % Properties props = new Properties(); InputStream stream = application.getResourceAsStream(/WEB-INF/myprops.properties); props.load(stream); stream.close(); % to load a properties file from inside the WEB-INF subdirectory of your web application. As a general note, however, you should really be doing this sort of thing in startup code of a servlet, which stashes the results as servlet context parameters for everyone else to use. Using scriptlets to mix functional logic into your JSP pages is going to cause you maintenance nightmares over time. Craig -- 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]
Re: Need Ideas... big problem! (long)
The servlet engine handles it for you. Definitely take a look at some examples and the servlet spec, and it'll start to make more sense. Christian J. Dechery To: [EMAIL PROTECTED] christian@fincc: ep.gov.brSubject: Re: Need Ideas... big problem! (long) 07/10/02 01:02 PM Please respond to Tomcat Users List exaclty... I looked on HttpServlet... request and response are passed as parameters... so I don't HAVE it. And since it's passed as a parameter I would have to change 150 JSPs to pass this new parameter... and I don't wanna change anything, only create a new class... if in the solution comes changing all the JSPs and classes I'm sure that's not the best one... I may have asked the wrong question... let's say: public class TesteDispatcher extends HttpServlet { private static final String CONTENT_TYPE = text/html; //Initialize global variables public void init() throws ServletException { } //Clean up resources public void destroy() { } public String doSomething() { // this is the method... } } Is there anyway doSomething() can know in which Context it was called? Remember that this class is in \common\classes. thanks for ur patience .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 14:23 Hi, Christian. I would recommend now taking a good look at the Java Servlet Specification and letting all these suggestions digest while you go through that. Things should start to make more sense once you have a better handle on servlets. Maybe take a look at the Tomcat servlet examples too. Your servlet should definitely have access to the request object, since if you look at the specs on HttpServlet, you'll see that it is passed as a parameter to its various methods. HTH, -Jeff Christian J. Dechery To: [EMAIL PROTECTED] christian@fin cc: ep.gov.br Subject: Re: Need Ideas... big problem! (long) 07/10/02 12:30 PM Please respond to Tomcat Users List But I want the code I would write in the A class... cuz I will create a Servlet to provide a connection to the JSPs, but I don't wanna change the JSPs... inside my Servlet (A) I don't have access to the request object. Could u write some example code for the A class to figure in which context the method doSomething() was called? Thanks... .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 13:51 On Wed, 10 Jul 2002, Christian J. Dechery wrote: Date: Wed, 10 Jul 2002 13:27:26 -0300 From: Christian J. Dechery [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] 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? Sure ... that's really easy. You've got at least the following options: * Call request.getContextPath() and you'll get the context path of the web application that is responding to this request. * The application
RE: Need Ideas... big problem! (long)
Please, check some docs and some servlet examples. You most certainly DO HAVE both the Response object and the Request object EVERY TIME your servlet is called. That's just how it works. Whether you choose to use the objects in your class's methods is up to you. Just because you don't choose to use them doesn't mean they aren't there. For example, a servlet extends HttpServlet. Here is the HttpServlet spec, right from the source: http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServlet .html Please note how the methods are called. So, what you REALLY need to do, in your code, is not doSomething() {}, but doSomething(HttpServletRequest req, HttpServletResponse resp) {}. Check the docs! John Turner [EMAIL PROTECTED] -Original Message- From: Christian J. Dechery [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 10, 2002 1:32 PM To: [EMAIL PROTECTED] Subject: Re: Need Ideas... big problem! (long) exaclty... I looked on HttpServlet... request and response are passed as parameters... so I don't HAVE it. And since it's passed as a parameter I would have to change 150 JSPs to pass this new parameter... and I don't wanna change anything, only create a new class... if in the solution comes changing all the JSPs and classes I'm sure that's not the best one... I may have asked the wrong question... let's say: public class TesteDispatcher extends HttpServlet { private static final String CONTENT_TYPE = text/html; //Initialize global variables public void init() throws ServletException { } //Clean up resources public void destroy() { } public String doSomething() { // this is the method... } } Is there anyway doSomething() can know in which Context it was called? Remember that this class is in \common\classes. thanks for ur patience .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 14:23 Hi, Christian. I would recommend now taking a good look at the Java Servlet Specification and letting all these suggestions digest while you go through that. Things should start to make more sense once you have a better handle on servlets. Maybe take a look at the Tomcat servlet examples too. Your servlet should definitely have access to the request object, since if you look at the specs on HttpServlet, you'll see that it is passed as a parameter to its various methods. HTH, -Jeff Christian J. Dechery To: [EMAIL PROTECTED] christian@fin cc: ep.gov.br Subject: Re: Need Ideas... big problem! (long) 07/10/02 12:30 PM Please respond to Tomcat Users List But I want the code I would write in the A class... cuz I will create a Servlet to provide a connection to the JSPs, but I don't wanna change the JSPs... inside my Servlet (A) I don't have access to the request object. Could u write some example code for the A class to figure in which context the method doSomething() was called? Thanks... .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 13:51 On Wed, 10 Jul 2002, Christian J. Dechery wrote: Date: Wed, 10 Jul 2002 13:27:26 -0300 From: Christian J. Dechery [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] 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? Sure ... that's really easy. You've got at least the following options: * Call request.getContextPath() and you'll get the context path of the web application that is responding to this request. * The application object in a JSP page is in fact the ServletContext for the current webapp, so you can call things like % Properties props = new Properties(); InputStream stream = application.getResourceAsStream(/WEB-INF/myprops.properties); props.load(stream); stream.close(); % to load a properties file from inside the WEB-INF subdirectory of your web application. As a general note, however, you should really be doing this sort of thing in startup code of a servlet, which stashes the results as servlet context parameters for everyone else to use. Using scriptlets to mix functional logic into your JSP pages is going to cause you
RE: Need Ideas... big problem! (long)
And, BTW, you DON'T need to change any JSP pages to be able to use the Request and Response objects. They are there automatically. John Turner [EMAIL PROTECTED] -Original Message- From: Turner, John [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 10, 2002 1:51 PM To: 'Tomcat Users List' Subject: RE: Need Ideas... big problem! (long) Please, check some docs and some servlet examples. You most certainly DO HAVE both the Response object and the Request object EVERY TIME your servlet is called. That's just how it works. Whether you choose to use the objects in your class's methods is up to you. Just because you don't choose to use them doesn't mean they aren't there. For example, a servlet extends HttpServlet. Here is the HttpServlet spec, right from the source: http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServlet .html Please note how the methods are called. So, what you REALLY need to do, in your code, is not doSomething() {}, but doSomething(HttpServletRequest req, HttpServletResponse resp) {}. Check the docs! John Turner [EMAIL PROTECTED] -Original Message- From: Christian J. Dechery [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 10, 2002 1:32 PM To: [EMAIL PROTECTED] Subject: Re: Need Ideas... big problem! (long) exaclty... I looked on HttpServlet... request and response are passed as parameters... so I don't HAVE it. And since it's passed as a parameter I would have to change 150 JSPs to pass this new parameter... and I don't wanna change anything, only create a new class... if in the solution comes changing all the JSPs and classes I'm sure that's not the best one... I may have asked the wrong question... let's say: public class TesteDispatcher extends HttpServlet { private static final String CONTENT_TYPE = text/html; //Initialize global variables public void init() throws ServletException { } //Clean up resources public void destroy() { } public String doSomething() { // this is the method... } } Is there anyway doSomething() can know in which Context it was called? Remember that this class is in \common\classes. thanks for ur patience .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 14:23 Hi, Christian. I would recommend now taking a good look at the Java Servlet Specification and letting all these suggestions digest while you go through that. Things should start to make more sense once you have a better handle on servlets. Maybe take a look at the Tomcat servlet examples too. Your servlet should definitely have access to the request object, since if you look at the specs on HttpServlet, you'll see that it is passed as a parameter to its various methods. HTH, -Jeff Christian J. Dechery To: [EMAIL PROTECTED] christian@fin cc: ep.gov.br Subject: Re: Need Ideas... big problem! (long) 07/10/02 12:30 PM Please respond to Tomcat Users List But I want the code I would write in the A class... cuz I will create a Servlet to provide a connection to the JSPs, but I don't wanna change the JSPs... inside my Servlet (A) I don't have access to the request object. Could u write some example code for the A class to figure in which context the method doSomething() was called? Thanks... .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 13:51 On Wed, 10 Jul 2002, Christian J. Dechery wrote: Date: Wed, 10 Jul 2002 13:27:26 -0300 From: Christian J. Dechery [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] 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? Sure ... that's really easy. You've got at least the following options: * Call request.getContextPath() and you'll get the context path of the web application that is responding to this request. * The application object in a JSP page is in fact the ServletContext for the current webapp, so you can call things like % Properties props = new Properties(); InputStream stream = application.getResourceAsStream(/WEB-INF/myprops.properties); props.load(stream); stream.close(); % to load
RE: Need Ideas... big problem! (long)
But that's exactly what I'm talking about... if doSomething() has to receive parameters, then the answer to my question (like 10 posts ago) is NO - there is no WAY a class/Servlet can know in which context its method was called. This can only be done if the something is passed to this class: the Context itself or the Request and Response objects... right? I know little of the Servlet spec, but my question was so simple... I guess I didn't make myself clear. Sorry to bother you all... I now know that my problem has no solution. :(( .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 14:50 Please, check some docs and some servlet examples. You most certainly DO HAVE both the Response object and the Request object EVERY TIME your servlet is called. That's just how it works. Whether you choose to use the objects in your class's methods is up to you. Just because you don't choose to use them doesn't mean they aren't there. For example, a servlet extends HttpServlet. Here is the HttpServlet spec, right from the source: http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServlet .html Please note how the methods are called. So, what you REALLY need to do, in your code, is not doSomething() {}, but doSomething(HttpServletRequest req, HttpServletResponse resp) {}. Check the docs! John Turner [EMAIL PROTECTED] -Original Message- From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 10, 2002 1:32 PM To: [EMAIL PROTECTED] Subject: Re: Need Ideas... big problem! (long) exaclty... I looked on HttpServlet... request and response are passed as parameters... so I don't HAVE it. And since it's passed as a parameter I would have to change 150 JSPs to pass this new parameter... and I don't wanna change anything, only create a new class... if in the solution comes changing all the JSPs and classes I'm sure that's not the best one... I may have asked the wrong question... let's say: public class TesteDispatcher extends HttpServlet { private static final String CONTENT_TYPE = text/html; //Initialize global variables public void init() throws ServletException { } //Clean up resources public void destroy() { } public String doSomething() { // this is the method... } } Is there anyway doSomething() can know in which Context it was called? Remember that this class is in \common\classes. thanks for ur patience .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 14:23 Hi, Christian. I would recommend now taking a good look at the Java Servlet Specification and letting all these suggestions digest while you go through that. Things should start to make more sense once you have a better handle on servlets. Maybe take a look at the Tomcat servlet examples too. Your servlet should definitely have access to the request object, since if you look at the specs on HttpServlet, you'll see that it is passed as a parameter to its various methods. HTH, -Jeff Christian J. Dechery To: [EMAIL PROTECTED] christian@fin cc: ep.gov.br Subject: Re: Need Ideas... big problem! (long) 07/10/02 12:30 PM Please respond to Tomcat Users List But I want the code I would write in the A class... cuz I will create a Servlet to provide a connection to the JSPs, but I don't wanna change the JSPs... inside my Servlet (A) I don't have access to the request object. Could u write some example code for the A class to figure in which context the method doSomething() was called? Thanks... .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 13:51 On Wed, 10 Jul 2002, Christian J. Dechery wrote: Date: Wed, 10 Jul 2002 13:27:26 -0300 From: Christian J. Dechery [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] 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? Sure ... that's really easy. You've got at least the following options: * Call request.getContextPath() and you'll get the context path of the web application
RE: Need Ideas... big problem! (long)
hi, in a servlet, you can try : String contextpath = request.getContextPath(); or even : ServletContext sc = getServletContext(); String contextName = sc.getServletContextName(); If I understand your question correctly, this is at least one of the things you're asking about ? hope it helps -reynir -Original Message- From: Christian J. Dechery [mailto:[EMAIL PROTECTED]] Sent: 10. júlí 2002 17:56 To: [EMAIL PROTECTED] Subject: RE: Need Ideas... big problem! (long) But that's exactly what I'm talking about... if doSomething() has to receive parameters, then the answer to my question (like 10 posts ago) is NO - there is no WAY a class/Servlet can know in which context its method was called. This can only be done if the something is passed to this class: the Context itself or the Request and Response objects... right? I know little of the Servlet spec, but my question was so simple... I guess I didn't make myself clear. Sorry to bother you all... I now know that my problem has no solution. :(( .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 14:50 Please, check some docs and some servlet examples. You most certainly DO HAVE both the Response object and the Request object EVERY TIME your servlet is called. That's just how it works. Whether you choose to use the objects in your class's methods is up to you. Just because you don't choose to use them doesn't mean they aren't there. For example, a servlet extends HttpServlet. Here is the HttpServlet spec, right from the source: http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ht tp/HttpServlet .html Please note how the methods are called. So, what you REALLY need to do, in your code, is not doSomething() {}, but doSomething(HttpServletRequest req, HttpServletResponse resp) {}. Check the docs! John Turner [EMAIL PROTECTED] -Original Message- From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 10, 2002 1:32 PM To: [EMAIL PROTECTED] Subject: Re: Need Ideas... big problem! (long) exaclty... I looked on HttpServlet... request and response are passed as parameters... so I don't HAVE it. And since it's passed as a parameter I would have to change 150 JSPs to pass this new parameter... and I don't wanna change anything, only create a new class... if in the solution comes changing all the JSPs and classes I'm sure that's not the best one... I may have asked the wrong question... let's say: public class TesteDispatcher extends HttpServlet { private static final String CONTENT_TYPE = text/html; //Initialize global variables public void init() throws ServletException { } //Clean up resources public void destroy() { } public String doSomething() { // this is the method... } } Is there anyway doSomething() can know in which Context it was called? Remember that this class is in \common\classes. thanks for ur patience .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 14:23 Hi, Christian. I would recommend now taking a good look at the Java Servlet Specification and letting all these suggestions digest while you go through that. Things should start to make more sense once you have a better handle on servlets. Maybe take a look at the Tomcat servlet examples too. Your servlet should definitely have access to the request object, since if you look at the specs on HttpServlet, you'll see that it is passed as a parameter to its various methods. HTH, -Jeff Christian J. Dechery To: [EMAIL PROTECTED] christian@fin cc: ep.gov.br Subject: Re: Need Ideas... big problem! (long) 07/10/02 12:30 PM Please respond to Tomcat Users List But I want the code I would write in the A class... cuz I will create a Servlet to provide a connection to the JSPs, but I don't wanna change the JSPs... inside my Servlet (A) I don't have access to the request object. Could u write some example code for the A class to figure in which context the method doSomething() was called? Thanks... .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 13:51 On Wed, 10 Jul 2002, Christian J. Dechery wrote: Date: Wed, 10 Jul 2002 13:27:26 -0300 From: Christian J. Dechery [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] 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
RE: Need Ideas... big problem! (long)
I apologize if I didn't answer your question, but you've honestly got me going in circles. You're saying that your servlet can't know it's context unless it gets something passed to it (which it does), and your servlet can't have something passed to it because you don't want to change JSP pages, but you're not understanding that there would be no change to JSP pages, the Request and Response objects are there automatically, and all you have to do is reference them in your class. It's so simple, I don't understand what else you need. From your posts, it seems blatantly obvious to me that all you need to do is reference the Request object in your class's method, and then simply call the Request object's getContextPath() method. Then parse that to know whether you have the string (like the /test you used in your example) that you need!! BTW, this exact same explanation was posted by Craig a couple of hours ago. So, the solution to your question has been posted twice. Reference the Request object which is automatically there (you DON'T need to change any JSP's!) and then call getContextPath. Done! Have fun! John Turner [EMAIL PROTECTED] -Original Message- From: Christian J. Dechery [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 10, 2002 1:56 PM To: [EMAIL PROTECTED] Subject: RE: Need Ideas... big problem! (long) But that's exactly what I'm talking about... if doSomething() has to receive parameters, then the answer to my question (like 10 posts ago) is NO - there is no WAY a class/Servlet can know in which context its method was called. This can only be done if the something is passed to this class: the Context itself or the Request and Response objects... right? I know little of the Servlet spec, but my question was so simple... I guess I didn't make myself clear. Sorry to bother you all... I now know that my problem has no solution. :(( .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 14:50 Please, check some docs and some servlet examples. You most certainly DO HAVE both the Response object and the Request object EVERY TIME your servlet is called. That's just how it works. Whether you choose to use the objects in your class's methods is up to you. Just because you don't choose to use them doesn't mean they aren't there. For example, a servlet extends HttpServlet. Here is the HttpServlet spec, right from the source: http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServlet .html Please note how the methods are called. So, what you REALLY need to do, in your code, is not doSomething() {}, but doSomething(HttpServletRequest req, HttpServletResponse resp) {}. Check the docs! John Turner [EMAIL PROTECTED] -Original Message- From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 10, 2002 1:32 PM To: [EMAIL PROTECTED] Subject: Re: Need Ideas... big problem! (long) exaclty... I looked on HttpServlet... request and response are passed as parameters... so I don't HAVE it. And since it's passed as a parameter I would have to change 150 JSPs to pass this new parameter... and I don't wanna change anything, only create a new class... if in the solution comes changing all the JSPs and classes I'm sure that's not the best one... I may have asked the wrong question... let's say: public class TesteDispatcher extends HttpServlet { private static final String CONTENT_TYPE = text/html; //Initialize global variables public void init() throws ServletException { } //Clean up resources public void destroy() { } public String doSomething() { // this is the method... } } Is there anyway doSomething() can know in which Context it was called? Remember that this class is in \common\classes. thanks for ur patience .:| Christian J. Dechery .:| FINEP - Depto. de Sistemas .:| [EMAIL PROTECTED] .:| (21) 2555-0332 [EMAIL PROTECTED] 10/07/02 14:23 Hi, Christian. I would recommend now taking a good look at the Java Servlet Specification and letting all these suggestions digest while you go through that. Things should start to make more sense once you have a better handle on servlets. Maybe take a look at the Tomcat servlet examples too. Your servlet should definitely have access to the request object, since if you look at the specs on HttpServlet, you'll see that it is passed as a parameter to its various methods. HTH, -Jeff Christian J. Dechery To: [EMAIL PROTECTED] christian@fin cc: ep.gov.br Subject: Re: Need Ideas... big problem! (long) 07/10/02 12:30 PM Please respond to Tomcat Users List But I want the code I would write in the A class... cuz I will create a Servlet to provide a connection to the JSPs, but I don't wanna change the JSPs... inside my Servlet (A) I don't have access to the request object. Could u write some example code for the A class to figure in which
Re: Need Ideas... big problem! (long)
From: Christian J. Dechery [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, July 10, 2002 6:56 PM Subject: RE: Need Ideas... big problem! (long) But that's exactly what I'm talking about... if doSomething() has to receive parameters, then the answer to my question (like 10 posts ago) is NO - there is no WAY a class/Servlet can know in which context its method was called. This can only be done if the something is passed to this class: the Context itself or the Request and Response objects... right? know little of the Servlet spec, but my question was so simple... I guess I didn't make myself clear. Sorry to bother you all... I now know that my problem has no solution. :(( Come now, there is always a solution. It may not be pretty but there is always a way. Why does doSomething() need to be called? For a servlet there are three methods that you can use to perform processing service(), doPost() and doGet. Normally, you would not deal with service() but simply define an appropriate doPost or doGet method to do your processing. Both of these take as parameters the request and response objects. You should be aware of this as you have a working app. How does your webapp work? Do the users access a JSP and then that JSP performs all processing and displayes the results or is a servlet called when a user accesses a url and that servlet performs all the processing and forwards to a JSP to display the results? These are the two most common models. If you can let us know how your app works then we can help you. I can assure you that what you are trying to do is not outrageous. I have a very similar setup, I have the same webapp in development, test, prod, etc. My development/test box has a single instance of tomcat serving several virtual hosts with the same webapp connecting to different databases, etc. Regards. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Need Ideas... big problem! (long)
I think you need to start again and explain what the problem is you are trying to solve. Include snippets of code where relevant so that we know what you are doing even if you're not sure ;) Reading your posts you seems to think you know the solution while ignoring all that is being said. I would propose you repost the question as explain as clearly as possible what you want to do. We can and will help if you give us a chance. I know by what you are saying that it is possible but we do not have all day to explain the solution. You have most of the work done so let us see it and point you in the right direction. Have a look in you $TOMCAT/localhost/work/test. There you will see what the java source of the jsp page looks like. It's just a servlet in disguise. Have a look at it and you may tweak on what is being said to you... Don't give up yet... Donie -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Need Ideas... big problem! (long)
of code to your method, you can get a configurable parameter in ANY class: JSP, Servlet, Util class, and later in J2EE classes. So, you can use it for other parameters as well. ENV-ENTRY only lets you use the simple types in Java, but as you look deeper into JNDI you can have an initialization routine populate the JNDI environment with pretty much anything you want. And this doesn't even touch the larger scope for which JNDI was developed. However, this is a simple use of JNDI and directly solves your problem. Perhaps others will be able to able to take advantage of this technique as well. Also, it's not all my idea. I got all of this information from this thread, and simply consolidated it into this more comprehensive post. It's all the mailing lists fault, I had nothing to do with it. Good Luck! Best Regards, Will Hartung ([EMAIL PROTECTED]) - Original Message - From: Christian J. Dechery [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, July 10, 2002 6:33 AM 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. :) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Need Ideas... big problem! (long)
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]
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]
RE: Need Ideas... big problem! (long)
If you don't want to go the JNDI route, you could also do something like set init params in each application's web.xml file with the db connection info or create a .properties file for each application and read in the db connection info from that. HTH, -Jeff Kranson, Bob Bob_Kranson@compTo: 'Tomcat Users List' [EMAIL PROTECTED] uware.com cc: Subject: RE: Need Ideas... big problem! (long) 07/09/02 02:41 PM Please respond to Tomcat Users List 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]
RE: Need Ideas... big problem! (long)
Christian, I take this dynamic example from EJB definitions and usage. You will need to research the correct construct of the JNDI.PROPERTIES file. Essentially, you call to a flat file (jndi.properties) to obtain the database connection string. JNDI - Java Naming Directory Interface Jndi.properties would become the resource where the JDBC URL is stored. This can be interpreted loosely as a connection factory (in EJB terms). DataSource ds = (Datasource)ctx.lookup(java:comp/env/jdbc/ExampleDSRef); Connection conn = ds.getConnection(); Jndi.properties datasource.url jdbc:cloudscape://localhost:1313/user/pwd 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 3:47 PM To: [EMAIL PROTECTED] 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:tomcat-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] 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]
Re: Need Ideas... big problem! (long)
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]
RE: Need Ideas... big problem! (long) server.xml parameters
This is the best answer!! 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: Arshad Mahmood [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 09, 2002 4:42 PM To: Tomcat Users List Subject: Re: Need Ideas... big problem! (long) 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:tomcat-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] 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
Re: Need Ideas... big problem! (long)
The only detail with that is that the app.war is still different with each deployment. I always felt that there should be a bit in the Servlet (and J2EE for that matter) specs that has some kind of local properties file so deployers don't have to rebuild the WAR and EAR to make a configuration change. There are all sorts of mechanisms, they just need to write one of them down. If the app is deployed to seperate Tomcat engines, the URL could be defined on the command line (to steal Bobs example): java -Ddatasource.url=jdbc:cloudscape://localhost:1313/user/pwd. Or, as a simple JNDI like thing, simply stored in a properties file in the classpath. Properties p = new Properties(); p.load(ClassLoader.getSystemResourceAsStream(app.properties)); String jdbcInfo = p.getProperty(datasource.url); Mind you, this is essentially what Bobs JNDI suggestion does, but you don't have to actually understand anything about JNDI to use it, particularly for something this simple. (Though JNDI is worth looking into...) If they are all deployed in the same engine, from the same WAR, then this clearly will not work. If you want it to work in any servlet engine, then the Init Parameter in the WAR is the way to go. It sort of depends on how your apps are deployed. Regards, Will Hartung ([EMAIL PROTECTED]) - Original Message - From: [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, July 09, 2002 1:24 PM Subject: RE: Need Ideas... big problem! (long) If you don't want to go the JNDI route, you could also do something like set init params in each application's web.xml file with the db connection info or create a .properties file for each application and read in the db connection info from that. HTH, -Jeff Kranson, Bob Bob_Kranson@compTo: 'Tomcat Users List' [EMAIL PROTECTED] uware.com cc: Subject: RE: Need Ideas... big problem! (long) 07/09/02 02:41 PM Please respond to Tomcat Users List 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
Re: Need Ideas... big problem! (long)
On Tue, 9 Jul 2002, Will Hartung wrote: Date: Tue, 9 Jul 2002 14:18:12 -0700 From: Will Hartung [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Re: Need Ideas... big problem! (long) The only detail with that is that the app.war is still different with each deployment. I always felt that there should be a bit in the Servlet (and J2EE for that matter) specs that has some kind of local properties file so deployers don't have to rebuild the WAR and EAR to make a configuration change. There are all sorts of mechanisms, they just need to write one of them down. If the app is deployed to seperate Tomcat engines, the URL could be defined on the command line (to steal Bobs example): java -Ddatasource.url=jdbc:cloudscape://localhost:1313/user/pwd. Or, as a simple JNDI like thing, simply stored in a properties file in the classpath. It's already available, and it already is a simple JNDI thing :-). Check out the env-entry element in web.xml, which lets you define configuration parameters. You would do something like this in web.xml: env-entry env-entry-namedb.urlenv-entry-name env-entry-typejava.lang.String/env-entry-type /env-entry App servers let you customize the actual value assigned to this entry at deployment time. In Tomcat, you do that with an entry like this: Environment name=db.url type=java.lang.String value=jdbc:cloudscape://localhost:1313/user/pwd/ nested inside the Context element for this webapp. The net effect is that you can install the same unmodified WAR file on different servers (say, test and production) with connections automatically established to different databases. Getting the value inside your servlet is trivial: InitialContext context = new InitialContext(); String dburl = (String) context.lookup(java:comp/env/db.url); The java:comp/env thing is the standard place where environment entries get put. Properties p = new Properties(); p.load(ClassLoader.getSystemResourceAsStream(app.properties)); String jdbcInfo = p.getProperty(datasource.url); This won't work if you have more than one application on the same Tomcat instance, each trying to get it's own resources. Nothing stops you from implementing it yourself though. Mind you, this is essentially what Bobs JNDI suggestion does, but you don't have to actually understand anything about JNDI to use it, particularly for something this simple. (Though JNDI is worth looking into...) If they are all deployed in the same engine, from the same WAR, then this clearly will not work. If you want it to work in any servlet engine, then the Init Parameter in the WAR is the way to go. The env-entry thing is not quite that universal, but it will work on Tomcat and any J2EE app server -- that covers quite a bit of territory. It sort of depends on how your apps are deployed. Regards, Will Hartung ([EMAIL PROTECTED]) Craig - Original Message - From: [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, July 09, 2002 1:24 PM Subject: RE: Need Ideas... big problem! (long) If you don't want to go the JNDI route, you could also do something like set init params in each application's web.xml file with the db connection info or create a .properties file for each application and read in the db connection info from that. HTH, -Jeff Kranson, Bob Bob_Kranson@compTo: 'Tomcat Users List' [EMAIL PROTECTED] uware.com cc: Subject: RE: Need Ideas... big problem! (long) 07/09/02 02:41 PM Please respond to Tomcat Users List 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
Re: Need Ideas... big problem! (long)
From: Craig R. McClanahan [EMAIL PROTECTED] Sent: Tuesday, July 09, 2002 3:45 PM On Tue, 9 Jul 2002, Will Hartung wrote: From: Will Hartung [EMAIL PROTECTED] I always felt that there should be a bit in the Servlet (and J2EE for that matter) specs that has some kind of local properties file so deployers don't have to rebuild the WAR and EAR to make a configuration change. There are all sorts of mechanisms, they just need to write one of them down. It's already available, and it already is a simple JNDI thing :-). Check out the env-entry element in web.xml, which lets you define configuration parameters. You would do something like this in web.xml: env-entry env-entry-namedb.urlenv-entry-name env-entry-typejava.lang.String/env-entry-type /env-entry App servers let you customize the actual value assigned to this entry at deployment time. In Tomcat, you do that with an entry like this: Environment name=db.url type=java.lang.String value=jdbc:cloudscape://localhost:1313/user/pwd/ nested inside the Context element for this webapp. The net effect is that you can install the same unmodified WAR file on different servers (say, test and production) with connections automatically established to different databases. Ah! That's great. That's precisely the type of thing they need to write down, but that's the kind of thing that can go in the README of a WAR for particular servlet engines. I know that the They figure that all of this stuff will be done through some handy GUI util that explodes the WAR (or EAR, or whatever) for you, presents the XML files to be edited etc, and then squeezes them all back together in a nice friendly fashion. That's more relevant for EARs I suppose, but I still think a method external to the archive files is a better way to go. That way, you can potentially perform some kind of signing mechanism on the archive that doesn't get screwed up when its deployed. Anyway, thanx for the tip! Regards, Will Hartung ([EMAIL PROTECTED]) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Need Ideas... big problem! (long)
A quick and dirty solution I've done for this is to put a file called Server.properties in Tomcat's root classes directory, that contains things like the smtp host and if the server is running in live or test mode (a good thing to know if you're doing CC processing :-) My apps then look for the Server resource bundle, and act accordingly. Since the TOMCAT_HOME/classes directory is never touched by webapp deployment, I know it will remain configured correctly no matter how many times I deploy the app. James -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]