> -----Original Message-----
> From: Anand Desai [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 25, 2002 7:33 AM
> To: [EMAIL PROTECTED]
> Subject: My project directory in JSP/java.
>
>
> Hello,
>
> I would like create a file in my application-project
> directory of my tomcat
> installation. I instantiate an object in my JSP and I am using
> FileOutputStream tocreate the file.
> When I create a file, it gets created at a completely
> different place( under
> C:\Documents and setttings\... ) and not in my project . If I
> can get the
> full pathname of my project directory then I could create the
> files where I
> want.
> Can you please help?

Try this:

ServletContext context = getServletContext();

// Returns a String containing the real path for a given virtual path.
String strPath = context.getRealPath("MY PROJECT DIRECTORY");

This shall give you your projects directory path, irrespective of your
environment.
Then you can use your normal code to save the file.

>
> Thanks,
> Anand

Vikram
>
> ==============================================================
> =============
> To unsubscribe: mailto [EMAIL PROTECTED] with body:
> "signoff JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set
> JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to