tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Re[2]: Quick Question
Date Tue, 13 Aug 2002 16:13:44 GMT
Can I use something like this in my jsp page (instead of a java sevlet) to 
get the parameter name?,
before that I set the parameter in my web.xml file like this:

      <param-name>parameter name</param-name>

String value =  getServletContext().getInitParameter("parameter name");

because I'm confusing here because of the name "getServletContext"..... is 
it only works in a sevlet or it will work too in a jsp page???

thanks again 
Alex Tomita

13/08/2002 10:54 a.m.
Please respond to Tomcat Users List

        To:     Tomcat Users List <>
        cc:     Tomcat Users List <>
        Subject:        Re: Re[2]: Quick Question

My bean is WEB-INF/classes....

Jacob Kjome <>
13/08/2002 10:43 a.m.
Please respond to Tomcat Users List

        To:     Tomcat Users List <>
        Subject:        Re[2]: Quick Question


Where does your Bean exist?  Is it in one of Tomcat's classloaders, or
is it running out the WEB-INF/classes or WEB-INF/lib folder of your
webapp.  I'm geussing the it is in one of Tomcat's classloaders
meaning $CATALINA_HOME/common/lib, server/lib, or lib (shared/lib in

Those classloaders can't see the individual webapp classloaders.
However, libraries in your webapp *can* see Tomcat's plublic
classloaders (all bug server/lib, server/classes).

You may have to rearrange the location of your libraries.


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> 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 {
TLC>    public  int Connect()  {
TLC>    InputStream is = 
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> 1)..

TLC> The txt file is in "WEB-INF/classes/beans...", because "DbBean" is in 

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> 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> 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)" <>
TLC> 13/08/2002 08:11 a.m.
TLC> Please respond to Tomcat Users List

TLC>         To:     Tomcat Users List <>
TLC>         cc: 
TLC>         Subject:        RE: Quick Question

TLC> tomcats default directory is where ever you called the 

TLC> file.
TLC> So if you dont use another script to call the file 
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> //get context path
TLC>     ServletConfig scon = null ;
TLC>     String workingDir = null;
TLC>     public void init(ServletConfig config) {
TLC>         scon = config ;
TLC>      }
TLC>  public void doPost(HttpServletRequest request, HttpServletResponse
TLC> response)
TLC>     throws ServletException, IOException {
TLC>         //get working dir
TLC>         ServletContext sc = scon.getServletContext();
TLC>         workingDir = sc.getRealPath("");

TLC> --
TLC> To unsubscribe, e-mail:   <>
TLC> For additional commands, e-mail: <>

Best regards,

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message