web.xml - context-param not in order

2003-03-26 Thread David Thielen
Hi;

When I retrieve the param-name/param-value pairs from web.xml via:
Enumeration en = pageContext.getServletContext().getInitParameterNames();

It does not return them in the order they appear in web.xml. Is random order just part 
of the API definition?

thanks - dave

Re: web.xml - context-param not in order

2003-03-26 Thread p niemandt
Hi;

You are not guaranteed the order of the elements when using an
enumeration. This has more to do with basic data structures than with
the API. You would need to use a container that has a guaranteed order,
should you so wish.

This has to do with the dynamic nature of enumerations: They need to be
able to expand to store an unspecified amount of data. Should the
requirement enforce ordering on as well, you would loose the speed of
the enumeration.

You can always run through the enumeration, store this in an ArrayList,
and run Arrays.sort() on that, assuming that all the elements are
Comparable. Comparable - You must be able to call ElementA  ElementB
without getting a cast exception.

Have a look at the Java Collections Framework.


hth,
Paul

On Wed, 2003-03-26 at 21:55, David Thielen wrote:
 Hi;
 
 When I retrieve the param-name/param-value pairs from web.xml via:
 Enumeration en = pageContext.getServletContext().getInitParameterNames();
 
 It does not return them in the order they appear in web.xml. Is random order just 
 part of the API definition?
 
 thanks - dave
-- 
p niemandt [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Question about context-param

2003-01-16 Thread Mike Roest
Hi all,
	I'm trying to initialize a few parameters from my web.xml to be 
available to my context.

I'm just wondering when they become available.  As I'm attempting to 
access them during my Context constructor and I'm getting to following 
exception trace.

(This call was just trying to get the names not actually access the 
values but trying to access the values give similar results)

java.lang.NullPointerException
at 
javax.servlet.GenericServlet.getInitParameterNames(GenericServlet.java:167)
at polaris.servlet.PolarisContext.init(PolarisContext.java:54)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:296)
at java.lang.Class.newInstance(Class.java:249)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
java:902)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:821)
at 
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3420)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3
608)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:738)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347
)
at org.apache.catalina.core.StandardService.start(StandardService.java:4
97)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:218
9)
at org.apache.catalina.startup.Catalina.start(Catalina.java:512)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)

The only thing I can think of is that the context-param isn't accessable 
 until after the context constructor is finished. Which makes it not 
very helpfull for me.

If anyone has another way of doing this without putting it into a 
properties file I'm interested.

(The whole point of this is we're trying to migrate our properties to DB 
tables and need to give the app the DB user and password)

Thanks


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]



RE: Question about context-param

2003-01-16 Thread Shapira, Yoav
Howdy,
Your context constructor?  What's that?  Last I checked,
javax.servlet.ServletContext was an interface, and the container
provides an implementation.  

If you want to tie into the context lifecycle, which is a very valid
design, use a ServletContextListener implementation.  The context
parameters are available in that listener's contextInitialized() method.

Yoav Shapira
Millennium ChemInformatics


-Original Message-
From: Mike Roest [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 16, 2003 1:49 PM
To: [EMAIL PROTECTED]
Subject: Question about context-param

Hi all,
   I'm trying to initialize a few parameters from my web.xml to be
available to my context.

I'm just wondering when they become available.  As I'm attempting to
access them during my Context constructor and I'm getting to following
exception trace.

(This call was just trying to get the names not actually access the
values but trying to access the values give similar results)

java.lang.NullPointerException
at
javax.servlet.GenericServlet.getInitParameterNames(GenericServlet.java:
167)
at polaris.servlet.PolarisContext.init(PolarisContext.java:54)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructor
Acce
ssorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCon
stru
ctorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:296)
at java.lang.Class.newInstance(Class.java:249)
at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
java:902)
at
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:821)
at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.
java
:3420)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:3
608)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:738)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347
)
at
org.apache.catalina.core.StandardService.start(StandardService.java:4
97)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:218
9)
at org.apache.catalina.startup.Catalina.start(Catalina.java:512)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)

The only thing I can think of is that the context-param isn't
accessable
  until after the context constructor is finished. Which makes it not
very helpfull for me.

If anyone has another way of doing this without putting it into a
properties file I'm interested.

(The whole point of this is we're trying to migrate our properties to
DB
tables and need to give the app the DB user and password)

Thanks


--
To unsubscribe, e-mail:   mailto:tomcat-user-
[EMAIL PROTECTED]
For additional commands, e-mail: mailto:tomcat-user-
[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Question about context-param

2003-01-16 Thread Mike Roest
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.

Sorry for the confusion
Shapira, Yoav wrote:
Howdy,
Your context constructor?  What's that?  Last I checked,
javax.servlet.ServletContext was an interface, and the container
provides an implementation.  

If you want to tie into the context lifecycle, which is a very valid
design, use a ServletContextListener implementation.  The context
parameters are available in that listener's contextInitialized() method.

Yoav Shapira
Millennium ChemInformatics



-Original Message-
From: Mike Roest [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 16, 2003 1:49 PM
To: [EMAIL PROTECTED]
Subject: Question about context-param

Hi all,
	I'm trying to initialize a few parameters from my web.xml to be
available to my context.

I'm just wondering when they become available.  As I'm attempting to
access them during my Context constructor and I'm getting to following
exception trace.

(This call was just trying to get the names not actually access the
values but trying to access the values give similar results)

java.lang.NullPointerException
at
javax.servlet.GenericServlet.getInitParameterNames(GenericServlet.java:


167)


at polaris.servlet.PolarisContext.init(PolarisContext.java:54)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native


Method)


at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructor


Acce


ssorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCon


stru


ctorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:296)
at java.lang.Class.newInstance(Class.java:249)
at


org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.


java:902)
at


org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:821)


at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.


java


:3420)
at


org.apache.catalina.core.StandardContext.start(StandardContext.java:3


608)
at


org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)


at org.apache.catalina.core.StandardHost.start(StandardHost.java:738)
at


org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)


at


org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347


)
at


org.apache.catalina.core.StandardService.start(StandardService.java:4


97)
at


org.apache.catalina.core.StandardServer.start(StandardServer.java:218


9)
at org.apache.catalina.startup.Catalina.start(Catalina.java:512)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at


sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.


java:39)
at


sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces


sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)

The only thing I can think of is that the context-param isn't


accessable


until after the context constructor is finished. Which makes it not
very helpfull for me.

If anyone has another way of doing this without putting it into a
properties file I'm interested.

(The whole point of this is we're trying to migrate our properties to


DB


tables and need to give the app the DB user and password)

Thanks


--
To unsubscribe, e-mail:   mailto:tomcat-user-
[EMAIL PROTECTED]
For additional commands, e-mail: mailto:tomcat-user-
[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: Question about context-param

2003-01-16 Thread Shapira, Yoav
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.

Yoav Shapira
Millennium ChemInformatics

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Question about context-param

2003-01-16 Thread Mike Roest
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 the 
params from the web.xml.  Any Ideas?

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

web.xml:
?xml version=1.0 encoding=ISO-8859-1?

!DOCTYPE web-app
PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.2//EN
http://java.sun.com/j2ee/dtds/web-app_2.2.dtd;

web-app
context-param
	param-nameoraclePass/param-name
	param-valuepolaris/param-value
	/context-param
	context-param
	param-nameoracleUser/param-name
	param-valuepolaris/param-value
	/context-param
servlet
servlet-namePolarisContext/servlet-name
servlet-classpolaris.servlet.PolarisContext/servlet-class
	load-on-startup1/load-on-startup
	
/servlet
	
	security-constraint
		web-resource-collection
			web-resource-namepolaris/web-resource-name
			url-pattern/servlet/*/url-pattern
		/web-resource-collection

	/security-constraint


/web-app




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]



RE: Question about context-param

2003-01-16 Thread Shapira, Yoav
Howdy,

Ok that worked great. I don't get the exceptions anymore but for some
reason it's not pulling the
params from the web.xml.  Any Ideas?

If the code below is taken from a servlet, then this.getInitParameter()
will look for an init-parameter element inside the servlet element.
To get a context parameter from a servlet, you do:
String userName = getServletContext().getInitParameter(oracleUser);

By the way, I don't remember if you mentioned what tomcat version you're
using.  But if you're using tomcat 4.x, you web.xml should be compliant
with the 2.3 spec version, not 2.2.

Yoav Shapira
Millennium ChemInformatics

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Question about context-param

2003-01-16 Thread Mike Roest
Shapira, Yoav wrote:

Howdy,



Ok that worked great. I don't get the exceptions anymore but for some
reason it's not pulling the
params from the web.xml.  Any Ideas?



If the code below is taken from a servlet, then this.getInitParameter()
will look for an init-parameter element inside the servlet element.
To get a context parameter from a servlet, you do:
String userName = getServletContext().getInitParameter(oracleUser);

By the way, I don't remember if you mentioned what tomcat version you're
using.  But if you're using tomcat 4.x, you web.xml should be compliant
with the 2.3 spec version, not 2.2.


Yeah it's 4.1.18.  /me goes and changes the Spec

Thank you very much Yoav it's now working perfectly

I appreciate the help.


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




context-param

2003-01-15 Thread Geoff Peters
Yoav (or anyone else that can help me) - I made the changes to my web.xml file as 
recommended. Two questions:
1) do I need a seperate context-param tag for each context parameter, or can I put 
them all in the same block?
2) where is the best place to call getServletContext().getInitParameter(driver) 
within a servlet? In the init() method? Or on the fly, for example at the start of the 
doGet() method?

Thanks again, I appreciate the help!!

Geoff

-Original Message-
From: Shapira, Yoav [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 13, 2003 5:22 PM
To: Tomcat Users List
Subject: RE: Can't find servlet


Hi,
I didn't read previous messages in your thread, so my answer may be
incorrect / out of context... Why are you repeating all the init-params
that are the same, such as the driver?  It's better practice to have
just one context-param for this.  Every servlet can then get it by doing
getServletContext().getInitParameter(driver);

You don't need to declare your servlets in $CATALINA_HOME/conf/web.xml,
only in your own webapp's web.xml.

Yoav Shapira
Millennium ChemInformatics


-Original Message-
From: Geoff Peters [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 13, 2003 4:19 PM
To: Tomcat Users List
Subject: RE: Can't find servlet

John - You solved another one of my problems that I wasn't even sure
that I
had! (did that make sense??) If I uncomment that servlet-mapping block
for
the invoker my servlet works, if not, my servlet throws the servlet
not
available error. The funny thing is I have declared all of my servlets
in
my application web.xml, do I need to define these in the /conf/web.xml
as
well?

Here is my application web.xml, am I missing anything?

THANKS!!!

Geoff


?xml version=1.0 encoding=ISO-8859-1?

!DOCTYPE web-app
PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN
http://java.sun.com/dtd/web-app_2_3.dtd;

web-app

display-nameiFax Development/display-name
  description
iFax Development
  /description

   servlet

   servlet-namesend/servlet-name
   display-nameIfaxSend/display-name
   servlet-classIfaxSend/servlet-class
   init-param
   param-namedriver/param-name

param-valuesun.jdbc.odbc.JdbcOdbcDriver/param-value
   /init-param
   init-param
   param-nameuploadDir/param-name
   param-valued:\Work_Files\jakarta-tomcat-
4.1.18\webapps\IfaxSend\temp/param-value
   /init-param
   init-param
   param-nameodbc/param-name
   param-valuejdbc:odbc:replixdb/param-value
   /init-param
   init-param
   param-namedbUser/param-name
   param-valueuser/param-value
   /init-param
   init-param
   param-namedbPass/param-name
   param-valuepass/param-value
   /init-param

   /servlet

   servlet

   servlet-nameuserdetails/servlet-name
   display-nameIfaxUserDetails/display-name
   servlet-classIfaxUserDetails/servlet-class
   init-param
   param-namedriver/param-name

param-valuesun.jdbc.odbc.JdbcOdbcDriver/param-value
   /init-param
   init-param
   param-nameodbc/param-name
   param-valuejdbc:odbc:replixdb/param-value
   /init-param
   init-param
   param-namedbUser/param-name
   param-valueuser/param-value
   /init-param
   init-param
   param-namedbPass/param-name
   param-valuepass/param-value
   /init-param


   /servlet

   servlet

   servlet-nameonefax/servlet-name
   display-nameIfaxOneFax/display-name
   servlet-classIfaxOneFax/servlet-class
   init-param
   param-namedriver/param-name

param-valuesun.jdbc.odbc.JdbcOdbcDriver/param-value
   /init-param
   init-param
   param-nameodbc/param-name
   param-valuejdbc:odbc:replixdb/param-value
   /init-param
   init-param
   param-namedbUser/param-name
   param-valueuser/param-value
   /init-param
   init-param
   param-namedbPass/param-name
   param-valuepass/param-value
   /init-param
   init-param
   param-namefaxPath/param-name

param-valuec:\\Softlinx\\ReplixServer\\spool\\/param-
value
   /init-param
   init-param
   param-nameuploadDir/param-name
   param-valued:\Work_Files\jakarta-tomcat-
4.1.18\webapps

RE: context-param

2003-01-15 Thread Shapira, Yoav
Howdy,

1) do I need a seperate context-param tag for each context parameter,
or
can I put them all in the same block?

Separate context-param for each parameter.  They're just like
init-params in that way.  See the servlet specification's explanation of
the web.xml fields for more details.

2) where is the best place to call
getServletContext().getInitParameter(driver) within a servlet? In
the
init() method? Or on the fly, for example at the start of the doGet()
method?

Doesn't really matter.  It's always going to be available.  As their
name suggests, they're typically used during initialization to set up
things like database connections (and pools), JNDI entities, etc.  But
the servlet container is required to make the ServletContext available
to its servlets as long as the context is running.  So you can use it
anywhere: init, service methods, destroy...

Yoav Shapira
Millennium ChemInformatics

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: error accessing a context-param from web.xml

2002-09-04 Thread Irina Lishchenko

Probably your task is better to accomplish with JNDI Resources, 
http://localhost:8080/tomcat-docs/jndi-resources-howto.html
That is more elegant solution, and that is for what JNDI Resources are 
designed

Or are there any other reasons why do you want to carry out this 
context-param way?

ilis

On Tuesday 03 September 2002 19:55, you wrote:
 Hi,

 I am fairly new to using Tomcat.  I am attempting to use a centralized
 location to define the MySQL access configuration info.  It is my
 understanding that the /WEB-INF/web.xml is the best location to store
 this info.

 I have defined a set of JDBC parameters such as the driver info shown
 below in my web.xml file for the web app:

 context-param
 param-namejdbc.driver/param-name
 param-valuecom.mysql.jdbc.Driver/param-value
 /context-param
 ...


 Within a JSP file, I attempt to get the parameter via the implicit
 application variable:

 sql:setDataSource
 driver=%= application.getInitParameter(jdbc.driver) %
 url=%= application.getInitParameter(jdbc.url) %
 user=%= application.getInitParameter(jdbc.username) %
 password=%= application.getInitParameter(jdbc.password) %
 var=db /

 Unfortunately, I receive the following error:

 org.apache.jasper.compiler.ParseException:
 /search-all-cables.jsp(10,56) Attribute jdbc.driver has no value
 at
 org.apache.jasper.compiler.JspReader.parseAttributeValue(JspReader.java:563
) ...

 FYI, I am using Tomcat 4.0.4 with J2SDK 1.4.0_01.

 Thank you,
 Michael

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: error accessing a context-param from web.xml

2002-09-04 Thread jon wingfield

The error you are getting is the JSP parser mistaking the data %=
application.getInitParameter( as the value for the driver parameter of the
sql:setDataSource tag. Then it reports a parsing error as the next parameter
is sees is jdbc.driver with no '=', and hence no value, after it.

If you really want to set up a datasource this way try:

sql:setDataSource
driver='%= application.getInitParameter(jdbc.driver) %'
url='%= application.getInitParameter(jdbc.url) %'
user='%= application.getInitParameter(jdbc.username) %'
password='%= application.getInitParameter(jdbc.password) %'
var='db' /


Note the single quotes. This should work as there's nothing wrong with how
you are accessing the init params.

http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-resources-howto.html

-Original Message-
From: Michael R. Schwab [mailto:[EMAIL PROTECTED]]
Sent: 03 September 2002 18:56
To: Tomcat Users List
Subject: error accessing a context-param from web.xml


Hi,

I am fairly new to using Tomcat.  I am attempting to use a centralized
location to define the MySQL access configuration info.  It is my
understanding that the /WEB-INF/web.xml is the best location to store
this info.

I have defined a set of JDBC parameters such as the driver info shown
below in my web.xml file for the web app:

context-param
param-namejdbc.driver/param-name
param-valuecom.mysql.jdbc.Driver/param-value
/context-param
...


Within a JSP file, I attempt to get the parameter via the implicit
application variable:

sql:setDataSource
driver=%= application.getInitParameter(jdbc.driver) %
url=%= application.getInitParameter(jdbc.url) %
user=%= application.getInitParameter(jdbc.username) %
password=%= application.getInitParameter(jdbc.password) %
var=db /

Unfortunately, I receive the following error:

org.apache.jasper.compiler.ParseException:
/search-all-cables.jsp(10,56) Attribute jdbc.driver has no value
at
org.apache.jasper.compiler.JspReader.parseAttributeValue(JspReader.java:563)
...

FYI, I am using Tomcat 4.0.4 with J2SDK 1.4.0_01.

Thank you,
Michael
--
Michael R. Schwab
Design Engineer
QCC Communications Corp.
[EMAIL PROTECTED]
Voice: (306) 249-0220
Fax: (306) 249-5128


--
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: error accessing a context-param from web.xml

2002-09-04 Thread Michael R. Schwab

Thanks ilis and jon,

I'll take a look at JNDI.

Michael

On Wed, Sep 04, 2002 at 10:34:10AM +0100, jon wingfield wrote:
 The error you are getting is the JSP parser mistaking the data %=
 application.getInitParameter( as the value for the driver parameter of the
 sql:setDataSource tag. Then it reports a parsing error as the next parameter
 is sees is jdbc.driver with no '=', and hence no value, after it.
 
 If you really want to set up a datasource this way try:
 
 sql:setDataSource
 driver='%= application.getInitParameter(jdbc.driver) %'
 url='%= application.getInitParameter(jdbc.url) %'
 user='%= application.getInitParameter(jdbc.username) %'
 password='%= application.getInitParameter(jdbc.password) %'
 var='db' /
 
 
 Note the single quotes. This should work as there's nothing wrong with how
 you are accessing the init params.
 
 http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-resources-howto.html
 
 -Original Message-
 From: Michael R. Schwab [mailto:[EMAIL PROTECTED]]
 Sent: 03 September 2002 18:56
 To: Tomcat Users List
 Subject: error accessing a context-param from web.xml
 
 
 Hi,
 
 I am fairly new to using Tomcat.  I am attempting to use a centralized
 location to define the MySQL access configuration info.  It is my
 understanding that the /WEB-INF/web.xml is the best location to store
 this info.
 
 I have defined a set of JDBC parameters such as the driver info shown
 below in my web.xml file for the web app:
 
 context-param
 param-namejdbc.driver/param-name
 param-valuecom.mysql.jdbc.Driver/param-value
 /context-param
 ...
 
 
 Within a JSP file, I attempt to get the parameter via the implicit
 application variable:
 
 sql:setDataSource
 driver=%= application.getInitParameter(jdbc.driver) %
 url=%= application.getInitParameter(jdbc.url) %
 user=%= application.getInitParameter(jdbc.username) %
 password=%= application.getInitParameter(jdbc.password) %
 var=db /
 
 Unfortunately, I receive the following error:
 
 org.apache.jasper.compiler.ParseException:
 /search-all-cables.jsp(10,56) Attribute jdbc.driver has no value
 at
 org.apache.jasper.compiler.JspReader.parseAttributeValue(JspReader.java:563)
 ...
 
 FYI, I am using Tomcat 4.0.4 with J2SDK 1.4.0_01.
 
 Thank you,
 Michael
 --
 Michael R. Schwab
 Design Engineer
 QCC Communications Corp.
 [EMAIL PROTECTED]
 Voice: (306) 249-0220
 Fax: (306) 249-5128
 
 
 --
 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]
 

-- 
Michael R. Schwab
Design Engineer
QCC Communications Corp.
[EMAIL PROTECTED]
Voice: (306) 249-0220
Fax: (306) 249-5128


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




error accessing a context-param from web.xml

2002-09-03 Thread Michael R. Schwab

Hi,

I am fairly new to using Tomcat.  I am attempting to use a centralized
location to define the MySQL access configuration info.  It is my
understanding that the /WEB-INF/web.xml is the best location to store
this info.

I have defined a set of JDBC parameters such as the driver info shown
below in my web.xml file for the web app:

context-param
param-namejdbc.driver/param-name
param-valuecom.mysql.jdbc.Driver/param-value
/context-param
...


Within a JSP file, I attempt to get the parameter via the implicit
application variable:

sql:setDataSource
driver=%= application.getInitParameter(jdbc.driver) %
url=%= application.getInitParameter(jdbc.url) %
user=%= application.getInitParameter(jdbc.username) %
password=%= application.getInitParameter(jdbc.password) %
var=db /

Unfortunately, I receive the following error:

org.apache.jasper.compiler.ParseException:
/search-all-cables.jsp(10,56) Attribute jdbc.driver has no value
at org.apache.jasper.compiler.JspReader.parseAttributeValue(JspReader.java:563)
...

FYI, I am using Tomcat 4.0.4 with J2SDK 1.4.0_01.

Thank you,
Michael
-- 
Michael R. Schwab
Design Engineer
QCC Communications Corp.
[EMAIL PROTECTED]
Voice: (306) 249-0220
Fax: (306) 249-5128


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: context-param for a list/array of values ?

2002-07-24 Thread Shapira, Yoav

Howdy,
There are a couple of ways.  My favorite is:

param-namejndi.resources/param-name
param-valuejndi/a,jndi/b,jndi/c/param-value

String jndiString =
getServletContext().getInitParameter(jndi.resources);
StringTokenizer st = new StringTokenizer(jndiString, ,);
ArrayList jndiResources = new ArrayList();

while(st.hasMoreTokens())
{
  jndiResources.add(st.nextToken());
}

That's it, very simple.  ;)

Yoav Shapira
Millennium ChemInformatics


-Original Message-
From: Soefara Redzuan [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 23, 2002 7:08 PM
To: [EMAIL PROTECTED]
Subject: context-param for a list/array of values ?

In web.xml, variables can be defined like this,

  context-param
 param-namegui.bgcolor/param-name
 param-value#00/param-value
  /context-param

And then in your servlet or JSP,

  String guiBgColor =
getServletContext().getInitParameter(gui.bgcolor);

But how can I assign a list or array of values to a variable
in web.xml ?  For example, I wish to configure the available
JNDI datasources available to a webapp, so that the end user
can select one. Is it something like this ?

  context-param
 param-namejndi.resources/param-name
 param-valuejdbc/users/param-value
 param-valuejdbc/accounts/param-value
 param-valuejdbc/finance/param-value
  /context-param

But then how would I extract values in my JSP or servlet ?

Soefara

_
Join the world's largest e-mail service with MSN Hotmail.
http://www.hotmail.com


--
To unsubscribe, e-mail:   mailto:tomcat-user-
[EMAIL PROTECTED]
For additional commands, e-mail: mailto:tomcat-user-
[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: context-param for a list/array of values ?

2002-07-24 Thread Soefara Redzuan

From: Shapira, Yoav [EMAIL PROTECTED]
Subject: RE: context-param for a list/array of values ?

Howdy,
There are a couple of ways.  My favorite is:

param-namejndi.resources/param-name
param-valuejndi/a,jndi/b,jndi/c/param-value

String jndiString =
getServletContext().getInitParameter(jndi.resources);
StringTokenizer st = new StringTokenizer(jndiString, ,);
ArrayList jndiResources = new ArrayList();

while(st.hasMoreTokens())
{
   jndiResources.add(st.nextToken());
}

That's it, very simple.  ;)

Oh my, now why didn't I think of that ?  :)

I had thought there would be something like request.getParameterValues()
which allows us to detect an array of values.
Ex. a fictional getServletContext().getInitParameterValues()

Looks like I'll have to go with the String split instead :-)

Thank you, Yoav.

Soefara.



_
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




context param is null outside doGet

2002-06-08 Thread Mike Millson

Why is it that context parameters are null outside the doGet block of a
servlet?

For example, suppose I have the following in web.xml:

context-param
param-namebasepath/param-name
param-valuebob/param-value
/context-param

Why does Servlet 1 below print out bob while Sevlet 2 gives me a
NullPointerException error? Why isn't the context parameter available
outside the doGet block?

Servlet 1
==
public class Hello extends HttpServlet{

public void doGet(HttpServletRequest request HttpServletResponse response)
throws IOException, ServletException{

PrintWriter out = response.getWriter();
out.println(getServletContext()getInitParameter(basepath));
out.close();
}
}

Servlet 2
==
public class Hello extends HttpServlet{

private String basepath = getServletContext()getInitParameter(basepath);

public void doGet(HttpServletRequest request HttpServletResponse response)
throws IOException, ServletException{

PrintWriter out = response.getWriter();
out.println(basepath);
out.close();
}
}

Thank you,
Mike


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: context param is null outside doGet

2002-06-08 Thread jon wingfield

With out looking at the HttpServlet source to confirm i would guess that:
In servlet 2 the member variable basepath is assigned a value after the
super class (HttpServlet) constructor returns but before the servlets
init(...) method is called by the servlet container. Therefore at the time
of assignment the servlet context is not set on the servlet and a NPE
results. That would be my guess.
Override init(...) call super.init(...) and then assign the value to
basepath.

Jon

-Original Message-
From: Mike Millson [mailto:[EMAIL PROTECTED]]
Sent: 08 June 2002 14:55
To: Tomcat Users List
Subject: context param is null outside doGet


Why is it that context parameters are null outside the doGet block of a
servlet?

For example, suppose I have the following in web.xml:

context-param
param-namebasepath/param-name
param-valuebob/param-value
/context-param

Why does Servlet 1 below print out bob while Sevlet 2 gives me a
NullPointerException error? Why isn't the context parameter available
outside the doGet block?

Servlet 1
==
public class Hello extends HttpServlet{

public void doGet(HttpServletRequest request HttpServletResponse response)
throws IOException, ServletException{

PrintWriter out = response.getWriter();
out.println(getServletContext()getInitParameter(basepath));
out.close();
}
}

Servlet 2
==
public class Hello extends HttpServlet{

private String basepath = getServletContext()getInitParameter(basepath);

public void doGet(HttpServletRequest request HttpServletResponse response)
throws IOException, ServletException{

PrintWriter out = response.getWriter();
out.println(basepath);
out.close();
}
}

Thank you,
Mike


--
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]




problem with context-param in web.xml

2002-03-14 Thread Aline

Hello,

I work with Tomcat 4.0 and I'd like to set a context-param in my web.xml
file of my web application.
So I do this :

web-app

servlet
  servlet-nameadd/servlet-name
  servlet-classAddServlet/servlet-class
/servlet

context-param
 param-namelogFile/param-name

param-valuec:/jakarta-tomcat-4.0.1/webapps/myWebapps/file/param-value
 /context-param

 error-page
  exception-typejavax.servlet.UnavailableException/exception-type
  location /unavailable.html /location
 /error-page

/web-app


But when I declare my context-param and then when I restart my server, I
have a SAXException whitch explain me that the web.xml file is not correct.

Can anyone help me please?

thanks.
Aline
WEBCASTER
T +33 (0)3 28 36 25 25
F +33 (0)3 20 13 06 04
http://www.oeilpouroeil.fr
http://www.visiodrome.com



--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: problem with context-param in web.xml

2002-03-14 Thread Martin Heusel

Aline wrote:

 servlet
   servlet-nameadd/servlet-name
   servlet-classAddServlet/servlet-class
 /servlet

  a SAXException whitch explain me that the web.xml file is not correct.


there's a missing closing bracket /servlet-class ..

regards

   martin




--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: problem with context-param in web.xml

2002-03-14 Thread jmt

You've got to follow the order of ELEMENTS as specified in the Java Web 
Application Descriptor DTD :

servlet .../servlet is supposed to be after context-param 
.../context-param



jmt

On Thursday 14 March 2002 14:04, Aline wrote:
 Hello,

 I work with Tomcat 4.0 and I'd like to set a context-param in my web.xml
 file of my web application.
 So I do this :

 web-app

 servlet
   servlet-nameadd/servlet-name
   servlet-classAddServlet/servlet-class
 /servlet

 context-param
  param-namelogFile/param-name

 param-valuec:/jakarta-tomcat-4.0.1/webapps/myWebapps/file/param-value
  /context-param

  error-page
   exception-typejavax.servlet.UnavailableException/exception-type
   location /unavailable.html /location
  /error-page

 /web-app


 But when I declare my context-param and then when I restart my server, I
 have a SAXException whitch explain me that the web.xml file is not correct.

 Can anyone help me please?

 thanks.
 Aline
 WEBCASTER
 T +33 (0)3 28 36 25 25
 F +33 (0)3 20 13 06 04
 http://www.oeilpouroeil.fr
 http://www.visiodrome.com



 --
 To unsubscribe:   mailto:[EMAIL PROTECTED]
 For additional commands: mailto:[EMAIL PROTECTED]
 Troubles with the list: mailto:[EMAIL PROTECTED]

--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




R: problem with context-param in web.xml

2002-03-14 Thread Vercesi Paolo



 -Messaggio originale-
 Da: Aline [mailto:[EMAIL PROTECTED]]
 Inviato: giovedì 14 marzo 2002 14.05
 A: Tomcat Users List
 Oggetto: problem with context-param in web.xml
 
 
 Hello,
 
 I work with Tomcat 4.0 and I'd like to set a context-param in 
 my web.xml
 file of my web application.
 So I do this :
 
 web-app
 
 servlet
   servlet-nameadd/servlet-name
   servlet-classAddServlet/servlet-class
 
perhaps an angular bracket
is missing

 /servlet
 
 context-param
  param-namelogFile/param-name
 
 param-valuec:/jakarta-tomcat-4.0.1/webapps/myWebapps/file/p
 aram-value
  /context-param
 
  error-page
   exception-typejavax.servlet.UnavailableException/exception-type
   location /unavailable.html /location
  /error-page
 
 /web-app
 
 
 But when I declare my context-param and then when I restart 
 my server, I
 have a SAXException whitch explain me that the web.xml file 
 is not correct.
 
 Can anyone help me please?
 
 thanks.
 Aline

Best regards
Paolo

--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




RE: problem with context-param in web.xml

2002-03-14 Thread Yuval Levav

Hi,
I'm trying to integrate Cocoon with tomcat 4.0.1. I get the folowing
exception
during start-up:

java.io.FileNotFoundException
at
org.apache.naming.resources.DirContextURLConnection.getInputStream(DirContex
tURLConnection.java:344)
at org.apache.cocoon.Cocoon.init(Cocoon.java:131)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:852)
at
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:615)
at
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java
:396)
at
org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:243)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:201)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:2
46)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164
)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:170)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170
)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:163)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
1011)
at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106
)
at java.lang.Thread.run(Unknown Source)

How can I fix this problem ?

Yuval


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Access web.xml context-param From A Bean?

2002-02-17 Thread Kennedy Clark

I have values I want set at deployment time declared in my web.xml.  I am 
accessing these with no problem from my JSPs with:
%= application.getInitParameter(paramNameHere) %

However, for my business logic which I have pulled out the if JSPs and put 
into beans, I can't figure out how to access these values?  Is there way to 
get to values stored in the container from a bean?

TIA, Kennedy


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: Access web.xml context-param From A Bean?

2002-02-17 Thread Craig R. McClanahan



On Sun, 17 Feb 2002, Kennedy Clark wrote:

 Date: Sun, 17 Feb 2002 11:04:09 -0500
 From: Kennedy Clark [EMAIL PROTECTED]
 Reply-To: Tomcat Users List [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: Access web.xml context-param From A Bean?

 I have values I want set at deployment time declared in my web.xml.  I am
 accessing these with no problem from my JSPs with:
   %= application.getInitParameter(paramNameHere) %

 However, for my business logic which I have pulled out the if JSPs and put
 into beans, I can't figure out how to access these values?  Is there way to
 get to values stored in the container from a bean?


In order to access these parameters, you need a reference to the
ServletContext object for your web application, which is what a JSP page
sees as the application variable, inside your JavaBean.  For example,
you might include a setServletContext() method on your bean, and call it
when the bean is created.

An alternative approach that works in Tomcat 4 and any J2EE server is to
use environment entries instead of context initialization parameters
for this purpose.  For example, the following entry in web.xml:

env-entry
env-entry-nameparamNameHere/env-entry-name
env-entry-valueThis is the parameter value/env-entry-value
env-entry-typejava.lang.String/env-entry-type
/env-entry

can be accessed from a bean, running inside your web application, like
this:

import javax.naming.InitialContext;

public class FooBean {
...
InitialContext context = new InitialContext();
String paramValue = (String)
  context.lookup(java:comp/env/paramNameHere);
...
}

This works because the container provides an implementation of the
InitialContext APIs (from JNDI) that contains all the environment entries
configured in either the web.xml file or set by appropriate commands in
server.xml.  You don't need a direct reference to the ServletContext to
read them, so no setServletContext() method is required.

Besides environment entries, the JNDI InitialContext can be used to make
lots of other resources available to your web application (such as JDBC
connection pools) but allows them to be configured externally.  For more
information, see the JNDI Resources How-To in the Tomcat docs:

http://localhost:8080/tomcat-docs/jndi-resources-howto.html

or online at:

http://jakarta.apache.org/tomcat/tomcat-4.0-doc/jndi-resources-howto.html

 TIA, Kennedy


Craig


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




context-param [ hpux/nt tomcat 3.x 4.x ]

2001-09-04 Thread James, Stuart

Hi,

I want to access a context-param inside the  context tag of the main
server.xml file.

I can access  parameters inside the web.xml (stored in the web-inf)
directory, but that is stored inside the war/web project directory, how can
I access parameters declared in the main server.xml file.

Below is the code I use to iterate through the application parameters, so
what do I need to change for the top level context params ?

java.util.Enumeration appIter = application.getInitParameterNames();
while( appIter.hasMoreElements() )
{
String strName = (String)appIter.nextElement();
out.println( Application. + strName + BR );
}

I have tried the config, session and page objects but they didn't work
either.

Thanks in advance 
Stuart.

PS, yes I have already searched the web  archives. :)


___
Email Disclaimer

This communication is for the attention of the
named recipient only and should not be passed
on to any other person. Information relating to
any company or security, is for information
purposes only and should not be interpreted as
a solicitation or offer to buy or sell any security.
The information on which this communication is based
has been obtained from sources we believe to be reliable,
but we do not guarantee its accuracy or completeness.
All expressions of opinion are subject to change
without notice.  All e-mail messages, and associated attachments,
are subject to interception and monitoring for lawful business purposes.
___



Re: context-param [ hpux/nt tomcat 3.x 4.x ]

2001-09-04 Thread Craig R. McClanahan

There is no current support for setting context initialization parameters
in the server.xml file for any version of Tomcat.  If you'd like to
propose this, please submit an enhancement request to the bug tracking
system (under product category Tomcat 3 or Tomcat 4 as appropriate):

  http://nagoya.apache.org/bugzilla/

Craig McClanahan


On Tue, 4 Sep 2001, James, Stuart wrote:

 Date: Tue, 4 Sep 2001 17:31:48 +0100
 From: James, Stuart [EMAIL PROTECTED]
 Reply-To: [EMAIL PROTECTED]
 To: '[EMAIL PROTECTED]' [EMAIL PROTECTED]
 Subject: context-param [ hpux/nt tomcat 3.x  4.x ]

 Hi,

 I want to access a context-param inside the  context tag of the main
 server.xml file.

 I can access  parameters inside the web.xml (stored in the web-inf)
 directory, but that is stored inside the war/web project directory, how can
 I access parameters declared in the main server.xml file.

 Below is the code I use to iterate through the application parameters, so
 what do I need to change for the top level context params ?

 java.util.Enumeration appIter = application.getInitParameterNames();
 while( appIter.hasMoreElements() )
 {
 String strName = (String)appIter.nextElement();
 out.println( Application. + strName + BR );
 }

 I have tried the config, session and page objects but they didn't work
 either.

 Thanks in advance
 Stuart.

 PS, yes I have already searched the web  archives. :)


 ___
 Email Disclaimer

 This communication is for the attention of the
 named recipient only and should not be passed
 on to any other person. Information relating to
 any company or security, is for information
 purposes only and should not be interpreted as
 a solicitation or offer to buy or sell any security.
 The information on which this communication is based
 has been obtained from sources we believe to be reliable,
 but we do not guarantee its accuracy or completeness.
 All expressions of opinion are subject to change
 without notice.  All e-mail messages, and associated attachments,
 are subject to interception and monitoring for lawful business purposes.
 ___





Re: context-param

2001-09-01 Thread Craig R. McClanahan


On Tue, 28 Aug 2001, Mills, Theo wrote:

 Date: Tue, 28 Aug 2001 13:41:07 -0500
 From: Mills, Theo [EMAIL PROTECTED]
 Reply-To: [EMAIL PROTECTED]
 To: '[EMAIL PROTECTED]' [EMAIL PROTECTED]
 Subject: context-param

 Anyone know how to access an application-wide context-param from a servlet?


The simplest way is to use a context parameter in your web.xml file:

  context-param
param-nameglobal-name/param-name
param-valueThis is the parameter value/param-value
  /context-param

which you can retrieve from a servlet by calling:

  getServletContext().getInitParameter(global-name);

NOTE:  There are rules you *must* follow about the order of elements in
your web.xml file -- see the Servlet Specification, which you can download
from:

  http://java.sun.com/products/servlet/download.html

Craig McClanahan





context-param

2001-08-28 Thread Mills, Theo

Anyone know how to access an application-wide context-param from a servlet?



Getting context-param in servlet problems...ARGH

2001-04-24 Thread Marcel van Beurden (ETM)

Hi there,

I'm going slightly crazy. I want to get a parameter from the context-param section 
from my web.xml in my servlet. But I can't get it to work.

I quote from the example web.xml in the Tomcat docs:

quote
  The values actually assigned to these parameters can be retrieved in a servlet or 
JSP page by calling:

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

  where name matches the param-name element of one of these initialization 
parameters.
/quote

When I copy and paste this line of code into my init() method of my servlet I get a 
compilation error:

MyServlet.java: Error #: 300 : method getInitParameter(java.lang.String) not found 
in interface javax.servlet.ServletContext at line 35, column 40

I'm really confused now. My web.xml is below. Help !

Best regards,
Marcel

My web.xml:
?xml version=1.0 encoding=ISO-8859-1?

!DOCTYPE web-app
PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.2//EN
http://java.sun.com/j2ee/dtds/web-app_2_2.dtd;

web-app
context-param
param-namejdbcDriverName/param-name
param-valueorg.gjt.mm.mysql.Driver/param-value
/context-param
context-param
param-namejdbcConnectString/param-name
param-valuejdbc:mysql://localhost/db/param-value
/context-param

servlet
servlet-name
servlet1
/servlet-name
servlet-class
Servlet1
/servlet-class
/servlet

servlet
servlet-name
servlet2
/servlet-name
servlet-class
Servlet2
/servlet-class
/servlet

servlet-mapping
servlet-nameservlet1/servlet-name
url-pattern/*/url-pattern
/servlet-mapping

servlet-mapping
servlet-nameservlet2/servlet-name
url-pattern/log/*/url-pattern
/servlet-mapping

/web-app




AW: Getting context-param in servlet problems...ARGH

2001-04-24 Thread Ralph Einfeldt

I guess that your having a wrong JSDK in your classpath.

ServletContext.getInitParameter() has been introduced with JSDK 2.2.
Versions prior to this just had GenricServlet.getInitParmeter()
and ServletConfig..getInitParmeter().

 -Ursprüngliche Nachricht-
 Von: Marcel van Beurden (ETM)
 [mailto:[EMAIL PROTECTED]]
 Gesendet: Dienstag, 24. April 2001 09:21
 An: '[EMAIL PROTECTED]'
 Betreff: Getting context-param in servlet problems...ARGH
 
 
 Hi there,
 
 I'm going slightly crazy. I want to get a parameter from the 
 context-param section from my web.xml in my servlet. But I 
 can't get it to work.
 
 I quote from the example web.xml in the Tomcat docs:
 
 quote
   The values actually assigned to these parameters can be 
 retrieved in a servlet or JSP page by calling:
 
 String value = getServletContext().getInitParameter(name);
 
   where name matches the param-name element of one of 
 these initialization parameters.
 /quote
 
 When I copy and paste this line of code into my init() method 
 of my servlet I get a compilation error:
 
 MyServlet.java: Error #: 300 : method 
 getInitParameter(java.lang.String) not found in interface 
 javax.servlet.ServletContext at line 35, column 40
 
 I'm really confused now. My web.xml is below. Help !
 
 Best regards,
 Marcel
 
 My web.xml:
 ?xml version=1.0 encoding=ISO-8859-1?
 
 !DOCTYPE web-app
 PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.2//EN
 http://java.sun.com/j2ee/dtds/web-app_2_2.dtd;
 
 web-app
 context-param
 param-namejdbcDriverName/param-name
 param-valueorg.gjt.mm.mysql.Driver/param-value
 /context-param
 context-param
 param-namejdbcConnectString/param-name
 param-valuejdbc:mysql://localhost/db/param-value
 /context-param
 
 servlet
 servlet-name
 servlet1
 /servlet-name
 servlet-class
 Servlet1
 /servlet-class
 /servlet
 
 servlet
 servlet-name
 servlet2
 /servlet-name
 servlet-class
 Servlet2
 /servlet-class
 /servlet
 
 servlet-mapping
 servlet-nameservlet1/servlet-name
 url-pattern/*/url-pattern
 /servlet-mapping
 
 servlet-mapping
 servlet-nameservlet2/servlet-name
 url-pattern/log/*/url-pattern
 /servlet-mapping
 
 /web-app
 
 



RE: Getting context-param in servlet problems...SOLVED

2001-04-24 Thread Marcel van Beurden (ETM)

It's working now! Thanks again.

-Original Message-
From: Ralph Einfeldt [mailto:[EMAIL PROTECTED]]
Sent: dinsdag 24 april 2001 9:45
To: '[EMAIL PROTECTED]'
Subject: AW: Getting context-param in servlet problems...ARGH


I guess that your having a wrong JSDK in your classpath.

ServletContext.getInitParameter() has been introduced with JSDK 2.2.
Versions prior to this just had GenricServlet.getInitParmeter()
and ServletConfig..getInitParmeter().

 -Ursprüngliche Nachricht-
 Von: Marcel van Beurden (ETM)
 [mailto:[EMAIL PROTECTED]]
 Gesendet: Dienstag, 24. April 2001 09:21
 An: '[EMAIL PROTECTED]'
 Betreff: Getting context-param in servlet problems...ARGH
 
 
 Hi there,
 
 I'm going slightly crazy. I want to get a parameter from the 
 context-param section from my web.xml in my servlet. But I 
 can't get it to work.
 
 I quote from the example web.xml in the Tomcat docs:
 
 quote
   The values actually assigned to these parameters can be 
 retrieved in a servlet or JSP page by calling:
 
 String value = getServletContext().getInitParameter(name);
 
   where name matches the param-name element of one of 
 these initialization parameters.
 /quote
 
 When I copy and paste this line of code into my init() method 
 of my servlet I get a compilation error:
 
 MyServlet.java: Error #: 300 : method 
 getInitParameter(java.lang.String) not found in interface 
 javax.servlet.ServletContext at line 35, column 40
 
 I'm really confused now. My web.xml is below. Help !
 
 Best regards,
 Marcel
 
 My web.xml:
 ?xml version=1.0 encoding=ISO-8859-1?
 
 !DOCTYPE web-app
 PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.2//EN
 http://java.sun.com/j2ee/dtds/web-app_2_2.dtd;
 
 web-app
 context-param
 param-namejdbcDriverName/param-name
 param-valueorg.gjt.mm.mysql.Driver/param-value
 /context-param
 context-param
 param-namejdbcConnectString/param-name
 param-valuejdbc:mysql://localhost/db/param-value
 /context-param
 
 servlet
 servlet-name
 servlet1
 /servlet-name
 servlet-class
 Servlet1
 /servlet-class
 /servlet
 
 servlet
 servlet-name
 servlet2
 /servlet-name
 servlet-class
 Servlet2
 /servlet-class
 /servlet
 
 servlet-mapping
 servlet-nameservlet1/servlet-name
 url-pattern/*/url-pattern
 /servlet-mapping
 
 servlet-mapping
 servlet-nameservlet2/servlet-name
 url-pattern/log/*/url-pattern
 /servlet-mapping
 
 /web-app
 
 



global init param context-param

2001-02-26 Thread Brett W. McCoy

I am using context-param to set global variables for my servlets,
but my servlets are still not seeing them (the value is showing up as
null).  Here is an example:

 context-param
param-namebw.client.configDir/param-name
param-valueD:\dev\src\conf/param-value
  /context-param

And the code snippet using the param:

oamFileProps.load(config.getInitParameter("bw.client.configDir") +
System.getProperty("file.separator") +
   "SystemPref.properties");

And the exception being generated:

java.io.FileNotFoundException: null\SystemPref.properties (The system
cannot find the path specified)

I'm not sure why this is coming up as null.  Or should this be defined as
init-param for the servlets?  This could be a problem because there are
dozens and dozens of servlets using these parameters, and which ones those
are I don't know (I'm not part of the programming team for this, just the
sysadmin trying to deploy it all).  Again, this value was defined as a
global init parameter in the older JServ properties file.

-- Brett
 http://www.chapelperilous.net/~bmccoy/
---
Those who have had no share in the good fortunes of the mighty
Often have a share in their misfortunes.
-- Bertolt Brecht, "The Caucasian Chalk Circle"



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




RE: global init param context-param

2001-02-26 Thread Brett Knights


 oamFileProps.load(config.getInitParameter("bw.client.configDir") +
 System.getProperty("file.separator") +
"SystemPref.properties");
 
Context.getInitParameter for globals

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




RE: global init param context-param

2001-02-26 Thread Brett W. McCoy

On Mon, 26 Feb 2001, Brett Knights wrote:

  oamFileProps.load(config.getInitParameter("bw.client.configDir") +
  System.getProperty("file.separator") +
 "SystemPref.properties");
 
 Context.getInitParameter for globals

Argh, I was hoping you wouldn't suggest a code change.  :-)

-- Brett
 http://www.chapelperilous.net/~bmccoy/
---
A wise person makes his own decisions, a weak one obeys public opinion.
-- Chinese proverb


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




Context-param troubles...

2001-02-23 Thread Laurent LAUBIN

Hi everybody,

I'm definetly getting crasy with a context param ... I want to offer init
parameters to all my JSP pages... so In the WEB-INF/web.xml file of my
application, I've put something like :
...
  context-param
  param-nameRmiServer/param-name
  param-value//10.10.10.7/BOB/param-value
  description
 Nom de l'objet RMI de connexion.
  /description
/context-param   
...
Who can I retrieve this value from a JSP Pages... I've tried many things
like getServletContext().getInitPArameter("RmiServer"); and it always
returns null ...


Heppp Pleaaze 

Tcha.

___
Laurent LAUBIN  S2M
Ingnieur systme   2, rue des champs - BP 2282
Tl : +33 232 64 33 76  27950 St-Marcel - France
Fax : +33 232 21 25 99  http://www.s2m.fr/
___
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




tomcat 4 b1 and context param

2001-02-20 Thread Carlos

i writte this in the web.xml file and it reports me a error. Why?
thanks

context-param
param-nameEmpresa/param-name
/param-valueSN/param-value
/context-param


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




RE: tomcat 4 b1 and context param

2001-02-20 Thread Michael Wentzel

 i writte this in the web.xml file and it reports me a error. Why?
 thanks
 
 context-param
 param-nameEmpresa/param-name
 /param-valueSN/param-value
 /context-param

If this is the exact text then it is because you are starting the
param-value
tag with an end tag.  Replace the first /param-value with param-value.

---
Michael Wentzel
Software Developer
Software As We Think - http://www.aswethink.com
mailto:[EMAIL PROTECTED]

- Punisher of those who cannot spell dumb!

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




Re: tomcat 4 b1 and context param

2001-02-20 Thread Craig R. McClanahan

Michael Wentzel wrote:

  i writte this in the web.xml file and it reports me a error. Why?
  thanks
 
  context-param
  param-nameEmpresa/param-name
  /param-valueSN/param-value
  /context-param

 If this is the exact text then it is because you are starting the
 param-value
 tag with an end tag.  Replace the first /param-value with param-value.


You also need to make sure that this entry is in the correct order in the
web.xml file, as defined by the DTD.  Tomcat 4.0 uses a validating XML parser
to read this file, so you have to obey all the rule.s


 ---
 Michael Wentzel

Craig McClanahan



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




context-param: illegal char

2000-12-11 Thread Sam Terburg



with this code in web.xml:

 
context-param 
param-namedatabase_dsn/param-name 
param-valuejdbc:mysql://localhost/test?user=testpassword=test/param-value 
/context-param


i get this error:

Starting tomcat. Check logs/tomcat.log for error 
messages ERROR reading /home/jsp/forum/WEB-INF/web.xmlAt Next character 
must be ";" terminating reference to entity "password".

ERROR reading 
/home/jsp/forum/WEB-INF/web.xmljava.lang.NullPointerException 
at org.apache.tomcat.util.xml.XmlMapper.readXml(XmlMapper.java, Compiled 
Code) at 
org.apache.tomcat.context.WebXmlReader.processFile(WebXmlReader.java, Compiled 
Code) at 
org.apache.tomcat.context.WebXmlReader.contextInit(WebXmlReader.java, Compiled 
Code) at 
org.apache.tomcat.core.ContextManager.initContext(ContextManager.java, Compiled 
Code) at 
org.apache.tomcat.core.ContextManager.init(ContextManager.java:201) 
at 
org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:156) 
at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:163)

and

ERROR reading /home/jsp/forum/WEB-INF/web.xmlAt Illegal character or 
entity reference syntax.

and

bash: syntax error near unexpected token 
`password=test/param-value'



apparently  is an illegal character.
but how do i solve this problem?
i've thought of url_encoding this, but that's an ugly sollution.
anybody got a better idea?

Greets,

Sam.




Re: context-param: illegal char

2000-12-11 Thread Jon Skeet

 apparently  is an illegal character.
 but how do i solve this problem?
 i've thought of url_encoding this, but that's an ugly sollution.
 anybody got a better idea?

No, you need to *xml* encode it - use amp; instead of .

Jon



RE: context-param: illegal char

2000-12-11 Thread Nacho

Sorroundthe data, with a CDATA tag your web.xml excerpert will look
like:

 context-param
 param-namedatabase_dsn/param-name

param-value![CDATA[jdbc:mysql://localhost/test?user=testpassword=test]]/
param-value
 /context-param



Saludos ,
Ignacio J. Ortega

-Mensaje original-
De: Sam Terburg [mailto:[EMAIL PROTECTED]]
Enviado el: lunes 11 de diciembre de 2000 11:50
Para: [EMAIL PROTECTED]
Asunto: context-param: illegal char


with this code in web.xml:

 context-param
 param-namedatabase_dsn/param-name

param-valuejdbc:mysql://localhost/test?user=testpassword=test/param-valu
e
 /context-param


i get this error:

Starting tomcat. Check logs/tomcat.log for error messages 
ERROR reading /home/jsp/forum/WEB-INF/web.xml
At Next character must be ";" terminating reference to entity
"password".

ERROR reading /home/jsp/forum/WEB-INF/web.xml
java.lang.NullPointerException
 at org.apache.tomcat.util.xml.XmlMapper.readXml(XmlMapper.java,
Compiled Code)
 at
org.apache.tomcat.context.WebXmlReader.processFile(WebXmlReader.java,
Compiled Code)
 at
org.apache.tomcat.context.WebXmlReader.contextInit(WebXmlReader.java,
Compiled Code)
 at
org.apache.tomcat.core.ContextManager.initContext(ContextManager.java,
Compiled Code)
 at org.apache.tomcat.core.ContextManager.init(ContextManager.java:201)
 at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:156)
 at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:163)

and

ERROR reading /home/jsp/forum/WEB-INF/web.xml
At Illegal character or entity reference syntax.

and

bash: syntax error near unexpected token `password=test/param-value'



apparently  is an illegal character.
but how do i solve this problem?
i've thought of url_encoding this, but that's an ugly sollution.
anybody got a better idea?

Greets,

Sam.






Re: context-param: illegal char

2000-12-11 Thread Sam Terburg

Thanx, it workes.

Sam.



- Original Message - 
From: "Jon Skeet" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, December 11, 2000 11:50 AM
Subject: Re: context-param: illegal char


  apparently  is an illegal character.
  but how do i solve this problem?
  i've thought of url_encoding this, but that's an ugly sollution.
  anybody got a better idea?
 
 No, you need to *xml* encode it - use amp; instead of .
 
 Jon
 




RE: context-param: illegal char

2000-12-11 Thread G.Nagarajan



 
param-valuejdbc:mysql://localhost/test?user=testpassword=test/param-value
I 
think the  character is causing the problem, try replacing 
it
with 
amp;

Regards
Nagaraj.

  -Original Message-From: Sam Terburg 
  [mailto:[EMAIL PROTECTED]]Sent: Monday, December 11, 2000 
  11:50 AMTo: [EMAIL PROTECTED]Subject: 
  context-param: illegal char
  with this code in 
  web.xml:
  
   
  context-param 
  param-namedatabase_dsn/param-name 
  param-valuejdbc:mysql://localhost/test?user=testpassword=test/param-value 
  /context-param
  
  
  i get this error:
  
  Starting tomcat. Check logs/tomcat.log for error 
  messages ERROR reading /home/jsp/forum/WEB-INF/web.xmlAt Next 
  character must be ";" terminating reference to entity "password".
  
  ERROR reading 
  /home/jsp/forum/WEB-INF/web.xmljava.lang.NullPointerException 
  at org.apache.tomcat.util.xml.XmlMapper.readXml(XmlMapper.java, Compiled 
  Code) at 
  org.apache.tomcat.context.WebXmlReader.processFile(WebXmlReader.java, Compiled 
  Code) at 
  org.apache.tomcat.context.WebXmlReader.contextInit(WebXmlReader.java, Compiled 
  Code) at 
  org.apache.tomcat.core.ContextManager.initContext(ContextManager.java, 
  Compiled Code) at 
  org.apache.tomcat.core.ContextManager.init(ContextManager.java:201) 
  at 
  org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:156) 
  at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:163)
  
  and
  
  ERROR reading /home/jsp/forum/WEB-INF/web.xmlAt Illegal character or 
  entity reference syntax.
  
  and
  
  bash: syntax error near unexpected token 
  `password=test/param-value'
  
  
  
  apparently  is an illegal character.
  but how do i solve this problem?
  i've thought of url_encoding this, but that's an ugly sollution.
  anybody got a better idea?
  
  Greets,
  
  Sam.