Serving png from java servlet doesn't show up -


I want to return the canvas data as you want to upload an HTML canvas in Java servlet am and PNG image. My problem is that the response to the servlet is not correct and it is not presented as an image. Saving the file works well on the disk.

What am I doing wrong? Do I need to install more headers? Content-length?

  public void doPost (Acteepisaarlet request, Actiteepisrvet response response) throws IOException {BufferedImage bfi = null; OutputStream Out = Null; PrintWriter htmlOut = null; Try {response.setContentType ("image / png"); String img64 = (string) request.getParameter ("base64image"); Byte [] Decodedbytes = DataType Converter. PRBABBase 64 Binary (IMG64); Bfi = ImageIO.read (new bytereinputstream (decodedbits)); Out = response.getoutputstream (); ImageIO.write (BFI, "PNG", outside); // save on the disk file outputfile = new file ("webpage / saved penda"); ImageIO.write (BFI, "PNG", Output File); } Hold (Exception e) {// Error Handling} Finally {if (bfi! = Null) {bfi.flush (); } If (outside! = Null) {out.flush (); Out.close () ;; } If (html oops! = Null) {htmlOut.close (); }}}}  

Maybe I'm blind but I length on materials response object Title.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -