wood burning stoves 2.0*
The moose likes Servlets and the fly likes MultipartResponse(Sending Image and HTml Content )Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "MultipartResponse(Sending Image and HTml Content )Servlets" Watch "MultipartResponse(Sending Image and HTml Content )Servlets" New topic
Author

MultipartResponse(Sending Image and HTml Content )Servlets

Venkata Ramana Murty
Greenhorn

Joined: Nov 05, 2003
Posts: 1
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

Joined: Feb 20, 2001
Posts: 3695

Does the browser support multi-part responses?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: MultipartResponse(Sending Image and HTml Content )Servlets
 
Similar Threads
Downloading a document.
how image path should be passed to servlet
Creating MJPEG-stream/video with servlet, is this even possible?
Dynamic page content using out.flush()
Directory Download Servlet(Need your help asap!)