I tried the following:
   String tfilepath =
application.getRealPath("XML_Files")+tcustid+tsep+tordernumber+".xml";

but it appended "XML_FILES" to the file name, it did not write into the
directory XML_FILES!

Any idea, what am I doing wrong ?
Thanks

-----Original Message-----
From: Vikramjit Singh [mailto:vikramjits@;GTLLIMITED.COM]
Sent: Wednesday, November 13, 2002 4:17 AM
To: [EMAIL PROTECTED]
Subject: Re: getRealPath


you can hard code the file path like this

String tfilepath = application.getRealPath("XMLFiles");

but you can follow these tips to make it purely generic

? - "belief"

! - truth


? The file separator may not be /

! Use File.pathSeparator

? The current directory may not be where you expect.

! Ask the user to locate the file with a file dialog.

? Absolute paths may not begin with a file separator.

! Use the getCanonicalPath() method in the File class

? .. may not refer to the parent of the current directory

! use the getParent() method in the File class

? / may not be the root of the file system.

! Use File.listRoots() instead (Java 1.2)

? /tmp and /usr/tmp may not be real files

! Use File.createTempFile() instead (Java 1.2)


> -----Original Message-----
> From: Shahata, Ash [mailto:Ashraf_Shahata@;STERCOMM.COM]
> Sent: Wednesday, November 13, 2002 12:18 AM
> To: [EMAIL PROTECTED]
> Subject: getRealPath
>
>
> Hi all - I want to write a file to the context dir where Im
> running my jsp
> file, and I'm using getRealPath :
>   String tfilepath =
> application.getRealPath("/")+tcustid+tsep+tordernumber+".xml";
>
> this will write the file in the same dir as the jsp file,
> however I want the
> file to be written in a different directory... does anyone
> know how to do
> this? I tried adding the dir name after the "/" but it didnt work!
> Does anyone know how to change the directory so my file will
> get written in
> my required directory?
>
> Thanks
>
> ==============================================================
> =============
> 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
>
Disclaimer: This e-mail message along with any attachments is intended only
for the addressee and may contain confidential and privileged information of
GTL Limited. If the reader of this message is not the intended recipient,
you are notified that any dissemination, distribution or copy of this
communication is strictly prohibited. If you have received this message by
error, please notify us immediately, return the original mail to the sender
and delete the message from your system.

===========================================================================
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