"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:[EMAIL PROTECTED] > 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
