tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Roest <>
Subject Re: Question about context-param
Date Thu, 16 Jan 2003 20:37:18 GMT
Shapira, Yoav wrote:
> Howdy,
>>Sorry 2 different Contexts, and my brain was all messed up.  When I'm
>>refering to my Context
>>Constructor it's actually the main servlet constructor (which in our
> app is
>>PolarisContext).  Which
>>extends HttpServlet.
> OK, that makes a bit more sense.  Although a similar argument applies.
> Even though a servlet is a normal class, and you can create a
> constructor for it and do stuff in the constructor, you probably
> shouldn't.  Instead, stick with overriding Servlet methods, in this case
> init.  The container is required to make the servlet context parameters
> available to your servlet's init() method.  It's not required to make
> them available to your servlet's constructor.  So for portability and a
> little bit less of a headache, you're better off not writing a servlet
> constructor and moving the constructor code to the servlet's init()
> method.
Ok that worked great. I don't get the exceptions anymore but for some reason it's not pulling
params from the web.xml.  Any Ideas?

try {
      username = this.getInitParameter("oracleUser");
      password = this.getInitParameter("oraclePass");
      System.out.println("user: "+username+"\npass: "+password);
} catch(Exception e) { e.printStackTrace(); }

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
     PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"




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

View raw message