To follow up on Tim's suggestion:
use:
out = new
FileOutputStream(application.getRealPath("WEB-INF\\classes\\response.txt",
true);
(Here, 'application' has it's JSP meaning as the ServletContext, for a
GenericServlet, replace it by getServletContext()).
Of course, you are SOL if you doing this is you are using unpacked-war
files. In this case the best that you can do is:
out = new FileOutputStream(new
File(application.getAttribute("javax.servlet.context.tempdir"),"response.txt
"),true);
"Tim Funk" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Don't rely on relative paths. At any point in time - someone can change
> the current working directory and throw any preconceived notions way off.
>
> Use absolute paths. Get the base path directory by configuring it in
> web.xml or server.xml.
>
> -Tim
>
> runu rathi wrote:
> > Hi all,
> > I am using the following statement in my .java file
> >
> > out = new FileOutputStream("responses.txt", true);
> >
> > I assumed that it should write in a file in the same
> > directory as the .java file in web-inf/classes
> >
> > but instead it writes in C:\WINNT\system32
> >
> > How can I get it to write at a particular place using
> > relative paths.
> >
> > I shall appreciate any help.
> > Thanks,
> > Runu
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]