tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rodrigo Ruiz <rr...@gridsystems.com>
Subject Re: What is accepted way to read/write files in Tomcat ?
Date Thu, 15 Apr 2004 15:36:06 GMT
Some thoughts on this matter :-)

If I am not wrong, the servlet specification states that the directory 
pointed by "javax.servlet.context.tempdir" can be cleaned on restart (it 
is left to the container implementation). I think Tomcat does not do 
such a cleaning, but other containers (or even future Tomcat versions) 
are perfectly allowed to do so :-S

So, sticking to the specification, I guess the only way left to define 
such a location is specifying it through JNDI.
This means that any webapp needing (for example) to work as file server 
are unnecessary difficult to implement. Having to implement a custom 
servlet that does the same as the default one, but accessing another 
directory out of the context, sounds to me like reinventing the wheel :-D

Having war deployments this lack of functionality, it has always seemed 
strange to me that the specification only considers mandatory this type 
of deployment.

Rodrigo Ruiz

Mike Curwen wrote:

>"Is it legitimate" depends on who you talk to. ;)
> 
>Purists (I don't mean that negatively) would remind you that the only
>'guaranteed' filepath available is the javax.servlet.context.tempdir .
>And getRealPath() would blow up on  you, if you were running your webapp
>from a WAR file.  
> 
>However, if *you* know that your app will only ever be used unpacked,
>then fully document this requirement, and go ahead and use
>getRealPath().
> 
>
>
>  
>
>>-----Original Message-----
>>From: Antony Paul [mailto:antonypaul24@hotmail.com] 
>>Sent: Thursday, April 15, 2004 12:28 AM
>>To: Tomcat Users List
>>Subject: What is accepted way to read/write files in Tomcat ?
>>
>>
>>Hi all,
>>  What is the best way to read and write file(the file 
>>locations are inside
>>context) in a servlet container. I was able to read file using
>>getResourceAsStream() but writing using 
>>URLConnection().getOutputStream() failed and throws  protocol 
>>doesn't support output - UnknownServiceException. Is it 
>>legitimate to use the getRealPath() to get the context root 
>>and write the file ?
>>
>>Antony Paul
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
>  
>



-- 
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.658 / Virus Database: 421 - Release Date: 09/04/2004


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message