tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Curwen" <gb_...@gb-im.com>
Subject RE: What is accepted way to read/write files in Tomcat ?
Date Thu, 15 Apr 2004 12:57:41 GMT
"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


Mime
View raw message