tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jordan Michaels <jor...@viviotech.net>
Subject Re: relative paths in web.xml
Date Wed, 10 Sep 2008 01:42:03 GMT
Hmm... I tried this, and it looks as though Tomcat still pre-pends the
"/home/myuser/public_html/" to my XML file. My servlet throws the error:

java.io.FileNotFoundException:
/home/myuser/public_html/path/to/tomcat/conf/myservlet/myxmlfile.xml

and my file is really located at:

/path/to/tomcat/conf/myservlet/myxmlfile.xml

I have multiple sites that need to have access to this same servlet with
the same XML file passed to it, and it would be great if I didn't have
to copy this file to each site for each HOST entry... IE:

<Host name="mydomain1.net" appBase="webapps">
       <Context path="" docBase="/home/myuser1/public_html/" />
</Host>

<Host name="mydomain2.net" appBase="webapps">
       <Context path="" docBase="/home/myuser2/public_html/" />
</Host>

<Host name="mydomain3.net" appBase="webapps">
       <Context path="" docBase="/home/myuser3/public_html/" />
</Host>

The way Tomcat is working now, I would have to copy that XML file that I
need to pass to the servlet to each user's "public_html" directory in
order for the servlet to use it (which would also make the file
web-accessible - not at all what I want).

Is there a way to tell Tomcat to not use the docbase when passing this
file to the servlet?

Thanks to all of you who responded both on-list and off. =) I really
appreciate your help!

Warm regards,
Jordan Michaels
Vivio Technologies
http://www.viviotech.net/
Open BlueDragon Steering Committee
Adobe Solution Provider


Bill Barker wrote:
> "Jordan Michaels" <jordan@viviotech.net> wrote in message 
> news:48C70B1D.2020907@viviotech.net...
>> I'm trying to set up a "init-param" in Tomcat's main web.xml file (the
>> one in $CATALINA_HOME/conf/web.xml) that looks similar to the following:
>>
>> <servlet>
>>        <servlet-name>myServlet</servlet-name>
>>        <servlet-class>path.to.my.Servlet</servlet-class>
>>        <init-param>
>>            <param-name>SOME_XML_FILE</param-name>
>>            <param-value>./conf/myservlet/myxmlfile.xml</param-value>
>>        </init-param>
>>        <load-on-startup>0</load-on-startup>
>> </servlet>
>>
>> and in my $CATALINA_HOME/conf/server.xml file, I have the following:
>>
>> <Host name="mydomain.net" appBase="webapps"
>>            unpackWARs="true" autoDeploy="true"
>>            xmlValidation="false" xmlNamespaceAware="false">
>>        <Context path="" docBase="/home/myuser/public_html/" />
>> </Host>
>>
>> My XML file is in $CATALINA_HOME/conf/myservlet/myxmlfile.xml, but
>> whenever I load this up, Tomcat looks for the file under the
>> /home/myuser/public_html/ folder.
>>
>> Is there a way that I can tell tomcat to look for a file that's relative
>> to the $CATALINA_HOME folder instead of my Context Docbase value? It
>> would be ideal if the Param-Value had no relation to the Context Docbase
>> value at all.
>>
>> Is this even possible with Tomcat?
>>
> 
> This feature is specific to Tomcat, but yes you can do it.  You would use:
>    <param-value>${catalina.home}/conf/myservlet/myxmlfile.xml</param-value>
> 
> When Tomcat parses your web.xml file, it will substitute the value for the 
> System property catalina.home.  Of course, this works for any System 
> property.
> 
> 
>> Thanks in advance for any help anyone can offer.
>>
>> -- 
>> Warm regards,
>> Jordan Michaels
>> Vivio Technologies
>> http://www.viviotech.net/
>> Open BlueDragon Steering Committee
>> Adobe Solution Provider
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message