Re: Re[4]: Quick Question
Hi, Alex. Since JSP's are turned into servlets before they are executed, I don't see why you couldn't do this. For your convenience, JSP's have some common objects already available for use. The application object is equivalent to the javax.servlet.ServletContext object you would get by doing a getServletContext() call. So, application.getInitParameter(key) should do the trick, too. HTH, -Jeff Jacob Kjome [EMAIL PROTECTED]To: Tomcat Users List [EMAIL PROTECTED] m cc: Subject: Re[4]: Quick Question 08/13/02 12:00 PM Please respond to Jacob Kjome Hello TOMITA, I know next to nothing about JSP. Haven't touched it. I use XMLC and Barracuda to do presentation. However, I would think that you should be able to use getServletContext() or something analogous in JSP. Jake Tuesday, August 13, 2002, 11:13:44 AM, you wrote: TLC Can I use something like this in my jsp page (instead of a java sevlet) to TLC get the parameter name?, TLC before that I set the parameter in my web.xml file like this: TLC context-param TLC param-nameparameter name/param-name TLC param-valuelocalhost/param-value TLC /context-param TLC String value = getServletContext().getInitParameter(parameter name); TLC because I'm confusing here because of the name getServletContext. is TLC it only works in a sevlet or it will work too in a jsp page??? TLC thanks again TLC Alex Tomita TLC [EMAIL PROTECTED] TLC 13/08/2002 10:54 a.m. TLC Please respond to Tomcat Users List TLC To: Tomcat Users List [EMAIL PROTECTED] TLC cc: Tomcat Users List [EMAIL PROTECTED] TLC Subject:Re: Re[2]: Quick Question TLC My bean is WEB-INF/classes TLC Jacob Kjome [EMAIL PROTECTED] TLC 13/08/2002 10:43 a.m. TLC Please respond to Tomcat Users List TLC To: Tomcat Users List [EMAIL PROTECTED] TLC cc: TLC Subject:Re[2]: Quick Question TLC Hello TOMITA, TLC Where does your Bean exist? Is it in one of Tomcat's classloaders, or TLC is it running out the WEB-INF/classes or WEB-INF/lib folder of your TLC webapp. I'm geussing the it is in one of Tomcat's classloaders TLC meaning $CATALINA_HOME/common/lib, server/lib, or lib (shared/lib in TLC Tomcat-4.1.x). TLC Those classloaders can't see the individual webapp classloaders. TLC However, libraries in your webapp *can* see Tomcat's plublic TLC classloaders (all bug server/lib, server/classes). TLC You may have to rearrange the location of your libraries. TLC Jake TLC Tuesday, August 13, 2002, 9:29:19 AM, you wrote: TLC Hi all, TLC I'm trying to resolve this problem with all the solutions that you TLC gave TLC me, but it doesn't work... TLC This is what I did: TLC in my java bean (not a servlet), I have this code: TLC public class DbBean { TLCpublic int Connect() { TLCInputStream is = TLC TLC Thread.currentThread().getContextClassLoader().getResourceAsStream (config.txt); TLC if (is == null) { TLC return 0; TLC } TLC else { TLC return 1; TLC } TLC } TLC then in my jsp, I called this method, and then I write the value (0 TLC or TLC 1).. TLC The txt file is in WEB-INF/classes/beans..., because DbBean is in TLC a TLC package called beans, and I start tomcat from TOMCAT_HOME/bin.. TLC When I load the jsp, the method Connect of the DbBean (java bean) TLC returned TLC 0, which means the InputStream is null, but if I put the txt file in TLC TOMCAT_HOME/bin, I had no problem, the method returned 1 why TLC is TLC that??.. I'm using Tomcat 3.2 TLC Do I need to set something else in Tomcat?? TLC thanks again TLC Alex Tomita TLC Drinkwater, GJ (Glen) [EMAIL PROTECTED] TLC
Re: Re[4]: Quick Question
Check out the API too. http://jakarta.apache.org/tomcat/tomcat-4.0-doc/servletapi/index.html Regards, Michael - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, August 13, 2002 1:08 PM Subject: Re: Re[4]: Quick Question Hi, Alex. Since JSP's are turned into servlets before they are executed, I don't see why you couldn't do this. For your convenience, JSP's have some common objects already available for use. The application object is equivalent to the javax.servlet.ServletContext object you would get by doing a getServletContext() call. So, application.getInitParameter(key) should do the trick, too. HTH, -Jeff Jacob Kjome [EMAIL PROTECTED]To: Tomcat Users List [EMAIL PROTECTED] m cc: Subject: Re[4]: Quick Question 08/13/02 12:00 PM Please respond to Jacob Kjome Hello TOMITA, I know next to nothing about JSP. Haven't touched it. I use XMLC and Barracuda to do presentation. However, I would think that you should be able to use getServletContext() or something analogous in JSP. Jake Tuesday, August 13, 2002, 11:13:44 AM, you wrote: TLC Can I use something like this in my jsp page (instead of a java sevlet) to TLC get the parameter name?, TLC before that I set the parameter in my web.xml file like this: TLC context-param TLC param-nameparameter name/param-name TLC param-valuelocalhost/param-value TLC /context-param TLC String value = getServletContext().getInitParameter(parameter name); TLC because I'm confusing here because of the name getServletContext. is TLC it only works in a sevlet or it will work too in a jsp page??? TLC thanks again TLC Alex Tomita TLC [EMAIL PROTECTED] TLC 13/08/2002 10:54 a.m. TLC Please respond to Tomcat Users List TLC To: Tomcat Users List [EMAIL PROTECTED] TLC cc: Tomcat Users List [EMAIL PROTECTED] TLC Subject:Re: Re[2]: Quick Question TLC My bean is WEB-INF/classes TLC Jacob Kjome [EMAIL PROTECTED] TLC 13/08/2002 10:43 a.m. TLC Please respond to Tomcat Users List TLC To: Tomcat Users List [EMAIL PROTECTED] TLC cc: TLC Subject:Re[2]: Quick Question TLC Hello TOMITA, TLC Where does your Bean exist? Is it in one of Tomcat's classloaders, or TLC is it running out the WEB-INF/classes or WEB-INF/lib folder of your TLC webapp. I'm geussing the it is in one of Tomcat's classloaders TLC meaning $CATALINA_HOME/common/lib, server/lib, or lib (shared/lib in TLC Tomcat-4.1.x). TLC Those classloaders can't see the individual webapp classloaders. TLC However, libraries in your webapp *can* see Tomcat's plublic TLC classloaders (all bug server/lib, server/classes). TLC You may have to rearrange the location of your libraries. TLC Jake TLC Tuesday, August 13, 2002, 9:29:19 AM, you wrote: TLC Hi all, TLC I'm trying to resolve this problem with all the solutions that you TLC gave TLC me, but it doesn't work... TLC This is what I did: TLC in my java bean (not a servlet), I have this code: TLC public class DbBean { TLCpublic int Connect() { TLCInputStream is = TLC TLC Thread.currentThread().getContextClassLoader().getResourceAsStream (config.txt); TLC if (is == null) { TLC return 0; TLC } TLC else { TLC return 1; TLC } TLC } TLC then in my jsp, I called this method, and then I write the value (0 TLC or TLC 1).. TLC The txt file is in WEB-INF/classes/beans..., because DbBean is in TLC a TLC package called beans, and I start tomcat from TOMCAT_HOME/bin.. TLC When I load the jsp, the method Connect of the DbBean (java bean) TLC returned TLC 0, which means the InputStream is null, but if I put the txt file in TLC TOMCAT_HOME/bin, I had no problem, the method returned 1 why TLC is TLC that??.. I'm using Tomcat 3.2 TLC Do I need to set something else in Tomcat?? TLC thanks again TLC Alex Tomita TLC Drinkwater, GJ (Glen) [EMAIL PROTECTED] TLC 13/08/2002 08:11 a.m. TLC Please respond to Tomcat Users List TLC To: Tomcat Users List [EMAIL PROTECTED] TLC cc: TLC Subject:RE: Quick Question TLC tomcats default directory is where ever you called the startup.sh/bat TLC file. TLC So if you dont use another script to call the startup.sh/bat file TLC tomcats TLC default will be the bin directory. TLC Use this code to find the directory where WEB-INF is. Then you can TLC traverse TLC your directory structure from there. TLC file://get context path TLC ServletConfig scon = null ; TLC String workingDir = null
Re: Re[4]: Quick Question
thanks for the information, I'm going to test it out. Michael E. Locasto [EMAIL PROTECTED] 13/08/2002 12:34 p.m. Please respond to Tomcat Users List To: Tomcat Users List [EMAIL PROTECTED] cc: Subject:Re: Re[4]: Quick Question Check out the API too. http://jakarta.apache.org/tomcat/tomcat-4.0-doc/servletapi/index.html Regards, Michael - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, August 13, 2002 1:08 PM Subject: Re: Re[4]: Quick Question Hi, Alex. Since JSP's are turned into servlets before they are executed, I don't see why you couldn't do this. For your convenience, JSP's have some common objects already available for use. The application object is equivalent to the javax.servlet.ServletContext object you would get by doing a getServletContext() call. So, application.getInitParameter(key) should do the trick, too. HTH, -Jeff Jacob Kjome [EMAIL PROTECTED]To: Tomcat Users List [EMAIL PROTECTED] m cc: Subject: Re[4]: Quick Question 08/13/02 12:00 PM Please respond to Jacob Kjome Hello TOMITA, I know next to nothing about JSP. Haven't touched it. I use XMLC and Barracuda to do presentation. However, I would think that you should be able to use getServletContext() or something analogous in JSP. Jake Tuesday, August 13, 2002, 11:13:44 AM, you wrote: TLC Can I use something like this in my jsp page (instead of a java sevlet) to TLC get the parameter name?, TLC before that I set the parameter in my web.xml file like this: TLC context-param TLC param-nameparameter name/param-name TLC param-valuelocalhost/param-value TLC /context-param TLC String value = getServletContext().getInitParameter(parameter name); TLC because I'm confusing here because of the name getServletContext. is TLC it only works in a sevlet or it will work too in a jsp page??? TLC thanks again TLC Alex Tomita TLC [EMAIL PROTECTED] TLC 13/08/2002 10:54 a.m. TLC Please respond to Tomcat Users List TLC To: Tomcat Users List [EMAIL PROTECTED] TLC cc: Tomcat Users List [EMAIL PROTECTED] TLC Subject:Re: Re[2]: Quick Question TLC My bean is WEB-INF/classes TLC Jacob Kjome [EMAIL PROTECTED] TLC 13/08/2002 10:43 a.m. TLC Please respond to Tomcat Users List TLC To: Tomcat Users List [EMAIL PROTECTED] TLC cc: TLC Subject:Re[2]: Quick Question TLC Hello TOMITA, TLC Where does your Bean exist? Is it in one of Tomcat's classloaders, or TLC is it running out the WEB-INF/classes or WEB-INF/lib folder of your TLC webapp. I'm geussing the it is in one of Tomcat's classloaders TLC meaning $CATALINA_HOME/common/lib, server/lib, or lib (shared/lib in TLC Tomcat-4.1.x). TLC Those classloaders can't see the individual webapp classloaders. TLC However, libraries in your webapp *can* see Tomcat's plublic TLC classloaders (all bug server/lib, server/classes). TLC You may have to rearrange the location of your libraries. TLC Jake TLC Tuesday, August 13, 2002, 9:29:19 AM, you wrote: TLC Hi all, TLC I'm trying to resolve this problem with all the solutions that you TLC gave TLC me, but it doesn't work... TLC This is what I did: TLC in my java bean (not a servlet), I have this code: TLC public class DbBean { TLCpublic int Connect() { TLCInputStream is = TLC TLC Thread.currentThread().getContextClassLoader().getResourceAsStream (config.txt); TLC if (is == null) { TLC return 0; TLC } TLC else { TLC return 1; TLC } TLC } TLC then in my jsp, I called this method, and then I write the value (0 TLC or TLC 1).. TLC The txt file is in WEB-INF/classes/beans..., because DbBean is in TLC a TLC package called beans, and I start tomcat from TOMCAT_HOME/bin.. TLC When I load the jsp, the method Connect of the DbBean (java bean) TLC returned TLC 0, which means the InputStream is null, but if I put the txt file in TLC TOMCAT_HOME/bin, I had no problem, the method returned 1 why TLC is TLC that??.. I'm using Tomcat 3.2 TLC Do I need to set something else in Tomcat?? TLC thanks again TLC Alex Tomita TLC Drinkwater, GJ (Glen) [EMAIL PROTECTED] TLC 13/08/2002 08:11 a.m. TLC Please respond to Tomcat Users List TLC To: Tomcat Users List [EMAIL PROTECTED] TLC cc: TLC Subject:RE: Quick Question TLC tomcats default directory is where ever you called the startup.sh/bat TLC file. TLC So if you dont use another script to call the startup.sh/bat file