Dear All, I have a problem over here, in the transfer of file from my client machine to the server machine....I am zipping the file in the client machine and sending to the server machine....In the server machine I am trying to unzip it and write it over there....
For contacting my server, initially i am getting the authentication.....it is all correct....no problem with the authentication work...the problem over here is.............i am having 3 files to be transfered to my server machine...the first file is getting transfered....after that the command prompt is just standing idle....it is not even coming to the prompt state...it is not even thowing any errors in the server console or in the client machine....
public void zipper(String file,String name) throws Exception { try { ZipOutputStream zipoutputstream = new ZipOutputStream(urlconnection.getOutputStream()); ZipEntry zipentry = new ZipEntry(name); zipentry.setMethod(ZipEntry.DEFLATED); zipoutputstream.putNextE ntry(zipentry); byte bytearray[] = new byte[1024]; File filedir = new File(file); FileInputStream fileinputstream = new FileInputStream(filedir); BufferedInputStream bufferedinputstream = new BufferedInputStream(fileinputstream); int length = 0; while((length=bufferedinputstream.read(bytearray)) != -1) { zipoutputstream.write(bytearray,0,length); }
fileinputstream.close(); bu fferedinputstream.close(); zipoutputstream.flush(); zipoutputstream.finish(); zi poutputstream.closeEntry(); zipoutputstream.close(); System.out.println("I am here...");
InputStream in = urlconnection.getInputStream(); while (in.read()!=-1); } catch(Exception exp) {System.out.println("I am from client: " + exp);} }
/* to make the URL connection with the server - begin */ public void makeConnection() { /* Authentication work is done over here - begin */ String setcookie=""; String cookie=""; try { URL theurl = new URL("http://192.168.10.55:8001/names.nsf?login&username=sakthivel&passw ord=12345"); HttpURLConnection.setFollowRedirects(false); HttpURLConnection hurl = (HttpURLConnection)theurl.openConnection(); hurl.connect(); setcookie = hurl.getHeaderField ("set-cookie"); int index=setcookie.indexOf(";"); cookie=(setcookie.substring(0,index)).trim(); hur l.disconnect(); hurl=null; theurl=null; } catch(Exception exp){exp.printStackTrace();} /* Authentication work is done over here - end */
/* to make the URL connection with the server - begin */ try { URL serverURL = new URL("http://192.168.10.55:8001/servlet/FileUploadServlet"); urlconnection= (HttpURLConnection)serverURL.openConnection(); urlconnection.setDoOutput(true); urlconnection.setRequestMethod("POST"); urlconnection.setRequestProperty("Cooki e",cookie); } catch(Exception exp) {System.out.println("Client machine: Error in Making Connection" + exp );} /* to make the URL connection with the server - end */ }
/* to disconnect the URL connection with the server - begin */ public void disconnectConnection() { try { System.runFinalization(); urlconnection.disconne ct(); urlconnection.getInputStream().close(); } catch(Exception exp) {System.out.println("Client machine: Error gets fired while disconnecting the connection" + exp);} } } /* to disconnect the URL connection with the server - end */
My Server side Program(servlet program) ******************************* import java.io.BufferedOutputStream; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import java.io.*; import java.util.*;
bufferedoutputstream.flush(); bufferedoutputstream.close(); zipinputst ream.closeEntry(); zipinputstream.close(); } } catch(IOException ioexception) {System.out.println("IOException occured in the Server: " + ioexception);} } // end of the method...
} // end of the class
P.S: Here, I am using the Domino Server, which is same as the Web Logic Server......Pl. post a reply....hanging over here for the past one week...any suggestion is highly appreciated....