• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MultipartResponse(Sending Image and HTml Content )Servlets

 
Venkata Ramana Murty
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Iam trying to send Image and Html/Plain Content using MultipartResponse Using Servlets,But the image is not dispplaying ,And Some junk Characters are coming in that place.I would Be thankful if any one can help me out.Code Also appended to the mail
Thanks in Advance
Murthy
Code:
ServletOutputStream out=param_Response.getOutputStream();


MultipartResponse multi = new MultipartResponse(param_Response);

multi.startResponse("text/plain");
out.println("On your mark");
multi.endResponse();

try { Thread.sleep(1000); } catch (InterruptedException e) { }

multi.startResponse("text/plain");
out.println("Get set");
multi.endResponse();

try { Thread.sleep(1000); } catch (InterruptedException e) { }

multi.startResponse("image/gif");
Image image = chart.getImage(600,400);

GifEncoder gif = new GifEncoder (image,out);
gif.encode();
//out.flush();
multi.endResponse();
try { Thread.sleep(1000); } catch (InterruptedException e) { }

multi.startResponse("text/plain");
out.println("Plain text After Image Content Set");
multi.endResponse();

try { Thread.sleep(1000); } catch (InterruptedException e) { }
multi.finish();
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the browser support multi-part responses?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic