tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Gainty" <mgai...@hotmail.com>
Subject Re: Servlet/JSP source code to save data in a file
Date Mon, 12 Feb 2007 02:01:34 GMT
also..make sure your container identifies write permissions in $TOMCAT_HOME/conf/catalina.policy

grant { permission java.io.FilePermission "/test.txt", "write"; };

HTH
Martin--
--------------------------------------------------------------------------- 
This e-mail message (including attachments, if any) is intended for the use of the individual
or entity to which it is addressed and may contain information that is privileged, proprietary
, confidential and exempt from disclosure. If you are not the intended recipient, you are
notified that any dissemination, distribution or copying of this communication is strictly
prohibited.
--------------------------------------------------------------------------- 
Le présent message électronique (y compris les pièces qui y sont annexées, le cas échéant)
s'adresse au destinataire indiqué et peut contenir des renseignements de caractère privé
ou confidentiel. Si vous n'êtes pas le destinataire de ce document, nous vous signalons qu'il
est strictement interdit de le diffuser, de le distribuer ou de le reproduire.
----- Original Message ----- 
From: "Rashmi Rubdi" <dev_subscriptions@yahoo.com>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Sunday, February 11, 2007 8:50 PM
Subject: Re: Servlet/JSP source code to save data in a file


Not the best code, but I guess this is close to what you're looking for:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index.jsp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head><title></title></head>
  <body>
  <jsp:useBean id="writeFile" class="test27.WriteFile"/>
  <jsp:setProperty name="writeFile" property="fileText" value="Some Text"/>
  The file was written : <jsp:getProperty name="writeFile" property="writeToFile"/>
  </body>
</html>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WriteFile.java
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
package test27;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public class WriteFile {
    String fileText;
    boolean writeToFile;
    public WriteFile() {
    }
    public String getFileText() {
        return fileText;
    }
    public void setFileText(String fileText) {
        this.fileText = fileText;
    }
    public boolean getWriteToFile() {
        try {
            BufferedWriter out = new BufferedWriter(new FileWriter("C://test.txt"));
            out.write(this.fileText);
            out.close();
            writeToFile = true;
        } catch (IOException e) {
            writeToFile = false;
            //Log the exception here
            e.printStackTrace();
        }
        return writeToFile;
    }
    public void setWriteToFile(boolean writeToFile) {
        this.writeToFile = writeToFile;
    }
}


-Rashmi


----- Original Message ----
From: Teh Noranis Mohd Aris <teh_noranis@yahoo.com>
To: users@tomcat.apache.org
Sent: Saturday, February 10, 2007 11:35:27 PM
Subject: Servlet/JSP source code to save data in a file


Dear all,
   
  Does anyone have the Servlet/JSP source code to save data in a file that will be located
in the server? I need the source code very urgently. I have my own version but it is not working.
Please help me! Thank you.
   
   
  Yours Sincerely,
  TEH NORANIS 


---------------------------------
Expecting? Get great news right away with email Auto-Check.
Try the Yahoo! Mail Beta.



____________________________________________________________________________________
TV dinner still cooling? 
Check out "Tonight's Picks" on Yahoo! TV.
http://tv.yahoo.com/

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


 
____________________________________________________________________________________
TV dinner still cooling? 
Check out "Tonight's Picks" on Yahoo! TV.
http://tv.yahoo.com/

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

Mime
View raw message