Note that there are some explanatory texts on larger screens.

plurals
  1. PONo images displayed when website called from self written webserver
    text
    copied!<p>I have <strong>Java webserver (no standard software ... self written)</strong>. Everything seems to work fine, but when I try to call a page that contains pictures, those pictures are not displayed. Do I have to send images with the output stream to the client? Am I missing an extra step?</p> <p>As there is too much code to post it here, here is a little outline what happens or is supposed to happen:</p> <pre><code>1. client logs in 2. client gets a session id and so on 3. the client is connected with an output stream 4. we built the response with the HTML-Code for a certain 'GET'-request 5. look what the GET-request is all about 6. send html response || file || image (not working yet) </code></pre> <p>So much for the basic outline ... </p> <p><strong>It sends css-files and stuff, but I still have a problem with images! Does anybody have an idea? How can I send images from a server to a browser? Thanks.</strong></p> <p>I check requests from the client and responses from the server with charles. It sends the files (like css or js) fine, but doesn't with images: though the status is "200 OK" the transfer-encoding is <em>chunked</em> ... I have no idea what that means!? Does anybody know?</p> <p>EDIT: Here is the file-reading code:</p> <pre><code> try{ File requestedFile = new File( file ); PrintStream out = new PrintStream( this.getHttpExchange().getResponseBody() ); // File wird geschickt: InputStream in = new FileInputStream( requestedFile ); byte content[] = new byte[(int)requestedFile.length()]; in.read( content ); try{ // some header stuff out.write( content ); } catch( Exception e ){ e.printStackTrace(); } in.close(); if(out!=null){ out.close(); System.out.println( "FILE " + uri + " SEND!" ); } } catch ( /*all exceptions*/ ) { // catch it ... } </code></pre>
 

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