Hi Yashujn,

Suppose you have a directory "myWebFiles" under the root of your Web
aplication, in your servlet code you can do that :

*1) INSIDE THE WEB APPLICATION PATH*
*
*
/* byteTowrite is type of byte[] */
try
{
String myWebFilesPath = getServletContext().getRealPath("/myWebFiles");
String fileName = "dataFile.xml";
FileOutPutStream localFile = new FileOutPutStrema(myWebFilesPath
+ fileName);
localFile.write(byteTowrite);
localFile.flush();
localFile.close();
}
catch { .../...}

*2) ANYWHERE ON THE SERVER WITH PARAMETER PATH*
*
*
*) in web.xml when you register your servlet, add a init parameter for your
servlet, call it "folderPath"
and give it the value you want (e.g "/var/www/myWebFiles/")

<init-param>
    <param-name>uploadedFilesFolderPath</param-name>
    <param-value>/var/www/myWebFiles/</param-value>
</init-param>

*) use it to write your file

/* byteTowrite is type of byte[] */
try
{
String myWebFilesPath
= getServletConfig().getInitParameter("uploadedFilesFolderPath");
String fileName = "dataFile.xml";
FileOutPutStream localFile = new FileOutPutStrem(myWebFilesPath + fileName);
localFile.write(byteTowrite);
localFile.flush();
localFile.close();
}
catch{.../...}

Of course, in this case, you have to config web.xml before deploying your
application, and tomcat runtime *must have write permission for the
folder /var/www/uploadedFiles/* in this exemple.

I hope it helps.

Look at the Servlet API javadoc for more details. It doesn't depends upon
GWT.

Regards.

Karim Duran

2012/2/16 yashujn <[email protected]>

> I am using tomcat server to for my GWT based project......
>
> I have to create a folder in the server and save .xml files in that
> folder.
>
> Need help regarding saving the file.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to