tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Smith <d...@cornell.edu>
Subject Re: Relative internal links
Date Thu, 05 Jun 2008 16:43:42 GMT
So we are still dealing with two separate issues here.

a) relative links in the browser -- these are expanded to full URIs by 
the browser based on the current page's uri and the link's relative 
uri.  Nothing tomcat can do about that and nothing that should 
behaviorally change from tomcat 5 to tomcat 6.

b) relative file paths in servlet code -- relative paths are flaky no 
matter what version of tomcat you use since it dependes on the working 
directory at the time tomcat was started as opposed to the webapp's path 
or current file's path.  I'd highly recommend using 
ServletContext.getResource() or ServletContext.getResourceAsStream() to 
read files stored within the webapp.   Both will properly provide access 
to resources within the same webapp.  Just use the full path relative to 
the top of your webapp like '/logs/MCRCServlets.log'.

--David

Walter Thompson wrote:

>I am talking about servlet code and configuration file information and
>links in the htlm pages on the server under the root directory. 
>
>-----Original Message-----
>From: David Smith [mailto:dns4@cornell.edu] 
>Sent: Wednesday, June 04, 2008 5:00 PM
>To: Tomcat Users List
>Subject: Re: Relative internal links
>
>You mention links like ../webapps/MCRCServlets/logs/MCRCServlets.log
>which implies these are presented in the browser, but then your talk
>about absolute paths like C:/www/.... implying a local read of the file
>system.  These don't normally go together.  Could you clarify how you
>are using these paths (from browser or servlet code)?
>
>--David
>
>Walter Thompson wrote:
>  
>
>>I have run into an issue with Tomcat6. In Tomcat5 we were using links 
>>like "../webapps/MCRCServlets/logs/MCRCServlet.log" in the Java Code.
>> 
>>I copied all of the folders over from Tomcat5 to Tomcat6 so that they 
>>have the same directory structure:
>> 
>>            webapps
>>                        root
>>                        MCRCServlets
>>                        Balancer
>> 
>>In all of the Java Code for the servlets and config files I have had 
>>to put absolute paths in like 
>>"C:/www/Tomcat6/MCRCSerlets/logs/MCRCServlet.log" for it to find the 
>>files.
>> 
>>Is there a configuration file that I can change to make the relative 
>>references work? What would the config code would I add?
>> 
>>I have searched everywhere for an answer to this quest and found no 
>>answers.
>> 
>>Thanks for any help anyone can offer!
>> 
>>Walter Thompson
>>Midland Certified Reagent Company
>>3112 W Cuthbert Avenue
>>Midland, Texas 79701
>> 
>>432-694-7950 Ph
>>432-694-2387 Fx
>> 
>> 
>>
>>  
>>    
>>
>
>
>---------------------------------------------------------------------
>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