aspose file tools*
The moose likes Servlets and the fly likes Client Abort Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Client Abort Exception" Watch "Client Abort Exception" New topic
Author

Client Abort Exception

holger Hahn
Greenhorn

Joined: Jun 14, 2005
Posts: 9
Hi
I'm a beginner in servlet - applet programming

I use an servlet which communicate with an applet over HTTP.
the servlet should send an byte array (represents an png.File) to the applet.(The byte Array comes from an EJB (HelperSession)
I use an DataOutputStream to send this byteArray.
While sending this Byte Array I get the following Exception:

Client Abort Exception:
java.net.SocketException: Software caused connection abort write Error

Please Help me to solve thge problem

Here is the Code:


----------------Applet----------------


private void getFiles() {

// ben�tigte ByteArrays
byte [] picBytes = null;
byte [] keyBytes = null;
SecretKey keyHolder = null;

String docID = getParameter("documentID");
String docSubID = getParameter("documentSubID");

buf.append("docID:" +docID);
buf.append("docSubID: "+docSubID);

try {
URL url = new URL(getCodeBase(),"helper?param=file&docID="+docID+"&docSubID="+docSubID);
buf.append("CodeBase: "+getCodeBase());
URLConnection uc = url.openConnection();
uc.setUseCaches(false);
uc.setDoInput(true);
uc.setDoOutput(false);
DataInputStream dis = new DataInputStream(uc.getInputStream());
int size = dis.readInt();
picBytes = new byte[size];

dis.read(picBytes,0,picBytes.length);

dis.close();

} catch (MalformedURLException mue){
buf.append("MalformedURLException: "+mue.getMessage());
} catch (IOException e) {
buf.append("IOException: "+e.getMessage());

}

try {
URL url2 = new URL(getCodeBase(),"helper?param=key&docID="+docID+"&docSubID="+docSubID);
URLConnection uc2 = url2.openConnection();

uc2.setUseCaches(false);
uc2.setDoInput(true);
uc2.setDoOutput(false);

DataInputStream dis = new DataInputStream(uc2.getInputStream());
int size = dis.readInt();
keyBytes = new byte[size];
int j=0;
dis.read(keyBytes,0,size);

dis.close();
buf.append("Gr��e keybytes: "+size);
System.out.println("Gr��e keybytes: "+size);
this.buf.append("L�nge keyBytes in Applet: "+keyBytes.length);


} catch (MalformedURLException mue){
buf.append("MalformedURLException: "+mue.getMessage());
} catch (IOException e) {
buf.append("IOException: "+e.getMessage());

}
keyHolder = new SecretKeySpec(keyBytes,"DESede");
//byte [] decBytes = decrypt.decryptByteArray(picBytes,keyHolder);
//buf.append("L�nge decBytes: "+decBytes.length);


image = Toolkit.getDefaultToolkit().createImage(picBytes,0,picBytes.length);

}//end getFiles


------------Servlet---------------



public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {


HelperSessionLocal hsl = null;
param = request.getParameter("param");
System.out.println("Parameter param: "+param);
String docID = request.getParameter("docID");
System.out.println("DocumentID: "+docID);
String docSubID = request.getParameter("docSubID");
System.out.println("DocumentSubID: "+docSubID);
response.setContentType("application/octet-stream");

try {
hsl = hslh.create();
}catch (CreateException ce){
System.out.println("Create Exception in HelperSession!"+
"\nFehler: "+ce.getMessage());
}
try {

if (param.equals("file")){

// picBytes = new byte[(int)hsl.getFile(docID,docSubID).length];
byte [] picBytes = hsl.getFile(docID,docSubID);
System.out.println("picBytes geholt:");
System.out.println("L�nge picBytes in HelperServlet: "+picBytes.length);
response.setContentLength(picBytes.length);
System.out.println("l�nge nach Konvertierung in int"+(int)picBytes.length);
DataOutputStream dos = new DataOutputStream(response.getOutputStream());
dos.writeInt(picBytes.length);
System.out.println("L�nge PicBytes geschrieben: "+(int)picBytes.length);
dos.write(picBytes,0,picBytes.length);
dos.flush();
dos.close();
System.out.println("picBytes geschrieben");



}else if (param.equals("key")){
//keyBytes = new byte[(int)hsl.getFileKey(docID,docSubID).length];
byte []keyBytes = hsl.getFileKey(docID,docSubID);
System.out.println("Keybytes geholt");
response.setContentLength(keyBytes.length);
System.out.println("L�nge keyBytes in HelperServlet: "+keyBytes.length);
DataOutputStream dos = new DataOutputStream(response.getOutputStream());
dos.writeInt(keyBytes.length);
System.out.println("L�nge keyBytes geschrieben"+(int)keyBytes.length);
dos.write(keyBytes,0,keyBytes.length);
dos.flush();
dos.close();
System.out.println("keyBytes geschrieben");

}//end elseif


}catch (IOException e){
System.out.println("IOException in HelperServlet: "+e.getMessage()
+e.getCause());


}catch (Exception e ){
System.out.println("Exception in HelperServlet: "+e.getMessage());

}



}


Thanks for your support in advance
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Client Abort Exception