automatically save file in server side...

how can i save a file(text or excel) automatically without anyuser intervention?

lets say a query is done and the result of that query is goin to save into a file(textfile or excel file) how im i going to save it in the server side? maybe a there is a foldername /extract file/.

Hope somebody can help me... Thanks in advanced!

[346 byte] By [bukoya] at [2007-10-2 16:19:49]
# 1

hello again.. this is a part of my codes that writes text files into the server

public void ReadWrite(ActionForm form){

AdminAccountBean adminForm = (AdminAccountBean)form;

String directory1="";

String directory2="";

File f = new File("DBConn.txt");

File f1 = new File("DBConn1.txt");

String dconnectString = "jdbc:oracle:thin:@"+adminForm.getDserv()+":"+adminForm.getDport()+":"+adminForm.getDbname();

String dconnectString1 = "jdbc:oracle:thin:@"+adminForm.getDserv1()+":"+adminForm.getDport1()+":"+adminForm.getDbname1();

try{

boolean success = (new File(adminForm.getDirectory())).delete();

if (!success) {

System.err.println("Error on deleting previous file");

}

}catch(Exception e){

e.printStackTrace();

}

directory1 = f.getAbsolutePath().toString();

directory2 = f1.getAbsolutePath().toString();

try{

boolean success = (new File(f.getAbsolutePath().toString())).delete();

if (!success) {

System.err.println("Error on deleting previous file");

}

}catch(Exception e){

e.printStackTrace();

}

try{

boolean success = (new File(f1.getAbsolutePath().toString())).delete();

if (!success) {

System.err.println("Error on deleting previous file");

}

}catch(Exception e){

e.printStackTrace();

}

Convert co = new Convert();

/*try {

BufferedWriter adminto = new BufferedWriter(new FileWriter(directory));

adminto.write(co.Encoder("encoded"));

adminto.write("\n");

adminto.write(co.Encoder(uname));

adminto.write("\n");

adminto.write(co.Encoder(pword));

adminto.close();

} catch (IOException e) {

e.printStackTrace();

}*/

try{

boolean success = (new File(directory1)).delete();

if (!success) {

System.err.println("Error on deleting previous file");

}

}catch(Exception e){

e.printStackTrace();

}

try {

DriverManager.registerDriver(new oracle.jdbc.OracleDriver());

Connection conn = DriverManager.getConnection(dconnectString,adminForm.getDuname(),adminForm.getDpword());

conn.setAutoCommit (false);

String sqldelete ="DELETE FROM GIIS_WEB_ADMIN";

PreparedStatement stmt = conn.prepareStatement(sqldelete);

stmt.executeUpdate();

String sql ="INSERT INTO GIIS_WEB_ADMIN VALUES('"+adminForm.getUname()+"','"+co.Encoder(adminForm.getPword())+"','A','encoded')";

PreparedStatement pstmt = conn.prepareStatement(sql);

pstmt.executeUpdate();

conn.commit();

conn.close();

Decode de = new Decode();

String encoded2 = co.Encoder(dconnectString1);

BufferedWriter adminto1 = new BufferedWriter(new FileWriter(directory1));

adminto1.write(co.Encoder(dconnectString));

adminto1.write("\n");

adminto1.write(co.Encoder(adminForm.getDuname()));

adminto1.write("\n");

adminto1.write(co.Encoder(adminForm.getDpword()));

adminto1.write("\n");

adminto1.write(co.Encoder(adminForm.getDsid()));

adminto1.write("\n");

adminto1.close();

BufferedWriter adminto2 = new BufferedWriter(new FileWriter(directory2));

adminto2.write(co.Encoder(dconnectString1));

adminto2.write("\n");

adminto2.write(co.Encoder(adminForm.getDuname1()));

adminto2.write("\n");

adminto2.write(co.Encoder(adminForm.getDpword1()));

adminto2.write("\n");

adminto2.write(co.Encoder(adminForm.getDsid1()));

adminto2.write("\n");

adminto2.close();

} catch (Exception e) {

e.printStackTrace();

}

}

jgalacambraa at 2007-7-13 17:13:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hello again and thanks again! I guess I'll start out with this one! thanks so much... guess i'll work other things with this one.Thanks again your a life saver!
bukoya at 2007-7-13 17:13:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
by the way what is your nationality?
jgalacambraa at 2007-7-13 17:13:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
OT: I'm a filipino... Why is that you ask?
bukoya at 2007-7-13 17:13:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
your name sounds like a coconut
jgalacambraa at 2007-7-13 17:13:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...