Note that there are some explanatory texts on larger screens.

plurals
  1. POjava.io.FileNotFoundException while uploading a file to web server
    primarykey
    data
    text
    <p>I am trying to upload a log file from an applet. The applet uploads a file to a web application (environment Struts 2, Jboss) and receives response (string) from the server</p> <p>I am using following code to connect, upload a (log) file and receive server response from a application hosted on localhost on Jboss, running at port 8080 :</p> <pre><code>byte[] myData = aData.getBytes(); /* Uploading the data */ URL myURL = new URL(aURL); URLConnection myConnection = myURL.openConnection(); myConnection.setDoOutput(true); myConnection.setUseCaches(false); myConnection.setDefaultUseCaches(false); myConnection.setRequestProperty("Content-type", "application/octet-stream"); OutputStream myOutputStream = myConnection.getOutputStream(); myOutputStream.write(myData); myOutputStream.flush(); myOutputStream.close(); /* Getting the response */ InputStream myInputStream = myConnection.getInputStream(); byte myBytes[] = new byte[1024]; StringBuffer myStringBuilder = new StringBuffer(); int myReadCount = myInputStream.read(myBytes); while (myReadCount &gt; 0) { myStringBuilder.append(new String(myBytes, 0, myReadCount)); myReadCount = myInputStream.read(myBytes); } return myStringBuilder.toString(); </code></pre> <p>On server side, Struts 2 is being used and and action is called to receive this file. The Following code is called at server side :</p> <pre><code>InputStream inputStream = request.getInputStream(); byte[] appletLog = UploadUtil.readFromInputStream(inputStream); //appletLog saved in db here; return UPLOAD_RESPONSE_SUCCESS; </code></pre> <p>Please note that the server side code executes fine, without any exception etc and file is saved in database successfully.</p> <p>But right after that a <strong>java.io.FileNotFoundException:</strong> is thrown at line <strong>[EDIT]</strong> <code>InputStream myInputStream = myConnection.getInputStream();</code>. I could not find the reason. I would really appreciate if someone can point out mistakes and provide Hints.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload