Servlet parameters different from the command line parameters?

Discussion in 'Java' started by Jonck van der Kogel, May 25, 2004.

  1. 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
    Jonck van der Kogel, May 25, 2004
    #1
    1. Advertising

  2. Jonck van der Kogel

    jAnO! Guest

    "Jonck van der Kogel" <> wrote in message
    news:...
    > -configFile="conf/config.cfg"
    >
    > <init-param>
    > <param-name>configFile</param-name>
    > <param-value>config.cfg</param-value> < sure thats the full path?
    > </init-param>
    jAnO!, May 25, 2004
    #2
    1. Advertising

  3. 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!" <> wrote in message news:<c8v8no$7rc$>...
    > "Jonck van der Kogel" <> wrote in message
    > news:...
    > > -configFile="conf/config.cfg"
    > >
    > > <init-param>
    > > <param-name>configFile</param-name>
    > > <param-value>config.cfg</param-value> < sure thats the full path?
    > > </init-param>
    Jonck van der Kogel, May 27, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lucas Cowald
    Replies:
    4
    Views:
    1,048
    Tohid
    Oct 23, 2003
  2. circuit_breaker
    Replies:
    2
    Views:
    1,993
    Jack Jia
    Apr 4, 2004
  3. Bernd Oninger
    Replies:
    1
    Views:
    787
    Martin Honnen
    Jul 7, 2004
  4. Replies:
    4
    Views:
    1,707
    Terry Hancock
    Apr 23, 2005
  5. Lucas Cowald

    RUN/execute a Command-Line command from an ASP page

    Lucas Cowald, Oct 22, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    232
    Genich
    Oct 22, 2003
Loading...

Share This Page