This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MultipartResponse(Sending Image and HTml Content )Servlets