aspose file tools*
The moose likes JSP and the fly likes How to create a  text file from server side Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to create a  text file from server side" Watch "How to create a  text file from server side" New topic
Author

How to create a text file from server side

Tien Duong Nguyen
Greenhorn

Joined: Oct 22, 2004
Posts: 22
Hi all,

My JSP is trying to create a new file from the server. Here is the code :

<%
String path = application.getRealPath("/toto.xml");
FileWriter writer = new FileWriter(path);
writer.write("<?xml version='1.0'?>");
out.write( "Success in creating toto.xml! " );

%>

However, I always get the error "Permission Denied", I guess i need to do some authentication, i.e. provide user name and password but not sure how to do it ?

Any help is greatly appreciated.

Regards,

Andy


SCEA (part 1), part 2,3 in progress<br /> <br />SCBCD,SCWCD,SCJP
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Does the user under which your container is running have sufficient permissions to write to that file?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Tien Duong Nguyen
Greenhorn

Joined: Oct 22, 2004
Posts: 22
My JSP , when deployed in localhost (tomcat ), can create the file but when it is deployed in the server ( tomcat ), could not and the exception is "Permission denied".

I also guess that the problem is the tomcat container does not have the right to write the file, and I need to do some authentication, e.g. provide the user name and password that is used for FileTransfer. But I do not know how to do the authentication.

Any help is greatly appreciated.

Regards,

Andy.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to create a text file from server side
 
Similar Threads
regarding file creation on server -very urgent
I/O operation in jsp
Java to XML
Writing to a server from an applet
Save form data to server hard disk via JSP