• Post Reply Bookmark Topic Watch Topic
  • New Topic

connecting and copying files in tomcat  RSS feed

Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello Ranchers,
Sorry to botjer you all but,I have a project I am working on,the application is web based so I am using jsp as the frontend tomcat as the application server,and Oraqcle/mysql as the database.
Now the scope of the program is to use the jsp page from a client system to connect to a bean which does the database connection,now when the user clicks on a button on the jsp page its suppose to trigger the bean to pick up the path to a file from a column in the databse which is on a server in a different system/environment.If path is found it follows the path to pick up the file which could also be in a different environment/system and copies it back to a folder on the server system I am not supposed to use ftp and I have tried a couple of thins and I keep on getting errors here is a sample of the last code I used and error

package empire;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import java.sql.*;

public class GetFile2
private String list=null;
private String id=null;
private String pref=null;
private String url=null;
private String fpath=null;
Connection connect = null;
ResultSet result = null;
PreparedStatement state = null;
Socket s;
ServerSocket ss;

public void setlist(String list)

public void setid(String id)

/* public void setpref(String pref)

} */

public String getlist()
return list;

public String getid()
return id;
/* public String getpref()
return pref;
} */

public GetFile2() throws ClassNotFoundException

public void getSocket(Socket s)
public boolean AccountValidate()
boolean validate=false;
String list1="";
String id1="";
String pref1="";


state=connect.prepareStatement("Select * from CLIENTS_TAB where CLIENT_ID='"+id+"'");
//String strQuery = "Select * from clients_Tab where client_id= ?";
//state = connect.createStatement();
ResultSet result = state.executeQuery();

id = result.getString(1);
pref = result.getString(2);
//list= result.getString(3);
fpath = result.getString(3);

System.out.println("path picked"+" "+fpath);


if(pref.equals("fixed") && list.equals("upload"))
s = new Socket("crux",1024);
System.out.println("CONNECTED To CLIENT");
ss = new ServerSocket(1024);
s = ss.accept();
FileInputStream in = new FileInputStream(fpath);
BufferedOutputStream bout=new BufferedOutputStream(s.getOutputStream());
int k;
System.out.println("FILE SENT");

BufferedInputStream fin = new BufferedInputStream(s.getInputStream());
FileOutputStream out=new FileOutputStream("c:\\roy\\java1.txt");
int k1;

System.out.println("FILE RECEIVED");

catch (Exception e)
System.out.println("ERROR SENDING sorry " + e);
// System.out.println("ERROR SENDING:"+e1);
/* catch(Exception e1)
System.out.println("ERROR SENDING:"+e1);
} */

return validate;


I get this error
Aug 23, 2005 6:53:36 PM org.apache.commons.modeler.Registry loadRegistry
INFO: Loading registry information
Aug 23, 2005 6:53:36 PM org.apache.commons.modeler.Registry getRegistry
INFO: Creating new Registry instance
Aug 23, 2005 6:53:37 PM org.apache.commons.modeler.Registry getServer
INFO: Creating MBeanServer
Aug 23, 2005 6:53:38 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on port 8080
Starting service Tomcat-Standalone
Apache Tomcat/4.1.12-LE-jdk14
Aug 23, 2005 6:54:00 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on port 8080
Aug 23, 2005 6:54:01 PM org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on tcp port 8009
Aug 23, 2005 6:54:01 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=16/391 config=C:\Program Files\Apache Group\Tomcat 4
path picked c:\roberts\java1.txt
ERROR SENDING sorry java.net.ConnectException: Connection refused: connect

guess I am stock any suggestions I would be very glad and if my whole approach is wrong pls tell me what thanks
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!