Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Servlet parameters different from the command line parameters?

Reply
Thread Tools

Servlet parameters different from the command line parameters?

 
 
Jonck van der Kogel
Guest
Posts: n/a
 
      05-25-2004
Hi everybody,
I'm having some problems passing parameters into my servlet and am
hoping that some of you may be able to help me.

I'm using a 3d party jar file, that (as their JavaDoc says) looks for
a configFile system parameter. When I run my app as a regular class
with a main method (which uses some classes from the 3d party jar)
from the command-line, I have to add the parameter
-configFile="conf/config.cfg"
When I add this parameter (which is the path to the config file)
everything works fine.

What I really need however is to use the classes from the 3d party jar
in a servlet. I thought at first that I could pass parameters to the
servlet by putting the following lines in my web.xml file (I'm using
Tomcat 5):

<init-param>
<param-name>configFile</param-name>
<param-value>config.cfg</param-value>
</init-param>

The paramaters are passed fine (tested it by using the
getInitParameters method), but the 3d party jar doesn't find it.

Therefore my question is, do the initial parameters that can be passed
in the web.xml file function as parameters that are passed on the
command-line or are they somehow different?
Is there a way to "fake it", in other words reading in the parameters
and then setting the system parameter that the 3d party jar is looking
for?

Thanks very much for any help, Jonck
 
Reply With Quote
 
 
 
 
jAnO!
Guest
Posts: n/a
 
      05-25-2004

"Jonck van der Kogel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> -configFile="conf/config.cfg"
>
> <init-param>
> <param-name>configFile</param-name>
> <param-value>config.cfg</param-value> < sure thats the full path?
> </init-param>




 
Reply With Quote
 
 
 
 
Jonck van der Kogel
Guest
Posts: n/a
 
      05-26-2004
Hi,
Thanks for your reply. It was indeed the full (relative) path, which
is how I understood you should do it, absolute paths tend to get
broken pretty quickly.

Anyway, I now fixed it by reading in the paramaters from an XML file
and then setting it in my app by calling: System.setProperty("myProp",
"myValue")

This works very well. I still have no idea why the initial parameter
was not working. If it turns out to be something other than a mistake
of mine I'll post it here (and if it's a bug of course let the Tomcat
developers know).

Regards, Jonck

"jAnO!" <(E-Mail Removed)> wrote in message news:<c8v8no$7rc$(E-Mail Removed)>...
> "Jonck van der Kogel" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > -configFile="conf/config.cfg"
> >
> > <init-param>
> > <param-name>configFile</param-name>
> > <param-value>config.cfg</param-value> < sure thats the full path?
> > </init-param>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to set different TCP_KEEPALIVE parameters for different socket ? Marco Python 0 03-13-2007 03:58 AM
Parameters (command line, preferences, user input) Kenneth P. Turvey Java 1 02-25-2006 10:10 AM
jdbc query works only with parameters given in command line magda muskala Java 0 02-15-2005 04:00 AM
How to get command line parameters? Tal Raveh Perl 2 06-14-2004 08:45 AM
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM



Advertisments