You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by joe udder <a2...@hotmail.com> on 2003/01/19 12:38:00 UTC

Some advice on getting webapp-root and reading/writing

Hello.

Does anyone have some advice to give me on the following ideas?


My first problem is to find the correct path to my files.
Is there a method to get the "document-root" of my webapp, so I only need to 
append "Images/jpg" and "WEB-INF/settings" to the path?

I suppose using URL's is the most platform independent method?


Example:

My webapp is located in "/var/www/waTest/WEB-INF/",
and the JPG's are in "/var/www/waTest/Images/jpg/".

Finally the XML's are located in "/var/www/waTest/WEB-INF/settings/".



The second problem is how to read/write the files, should I use FileReader 
or is there a better solution for webapps?

TIA

/ju


_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Some advice on getting webapp-root and reading/writing

Posted by mech <me...@rz.fh-augsburg.de>.
What you need is here:

1. In javax.servlet.HttpServletRequest you'll find getContextPath()

2. In javax.servlet.ServletContext there's a method
getResourceAsStream()

Michael


> -----Original Message-----
> From: joe udder [mailto:a2600@hotmail.com] 
> Sent: Sonntag, 19. Januar 2003 12:38
> To: tomcat-user@jakarta.apache.org
> Subject: Some advice on getting webapp-root and reading/writing
> 
> 
> Hello.
> 
> Does anyone have some advice to give me on the following ideas?
> 
> 
> My first problem is to find the correct path to my files.
> Is there a method to get the "document-root" of my webapp, so 
> I only need to 
> append "Images/jpg" and "WEB-INF/settings" to the path?
> 
> I suppose using URL's is the most platform independent method?
> 
> 
> Example:
> 
> My webapp is located in "/var/www/waTest/WEB-INF/",
> and the JPG's are in "/var/www/waTest/Images/jpg/".
> 
> Finally the XML's are located in "/var/www/waTest/WEB-INF/settings/".
> 
> 
> 
> The second problem is how to read/write the files, should I 
> use FileReader 
> or is there a better solution for webapps?
> 
> TIA
> 
> /ju
> 
> 
> _________________________________________________________________
> Protect your PC - get McAfee.com VirusScan Online 
> http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:tomcat-user-> unsubscribe@jakarta.apache.org>
> For 
> additional commands, 
> e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>