My problem is I want to write the character text as well as the binary data to the client in a single servlet.
I have the images in the database.I want to organize the image with in a table and then send to the client.For writing binary data to the client we need ServletOutputStream object which can be obtained by calling response.getOutputStream() method,moreover the content type should be set as either
Then how to send the html to the client i.e the HTML code required to organize the binary data with in a table.For this we need to set the content type as response.setContentType("text/html") and a PrintWriter object is needed to write the character text.If I add the follwing code
with in the same servlet in which the binary data is sent to the client automatically the error occurs.
The browser will send two requests, one for the image and another for the text. You CANNOT send both an image and text in the same response.
Joined: Jul 25, 2006
Thanks Mr.David O'Meara for your suggesstions.I know both binary data and text cannot be sent in a single response,so I asked for the alternative.It will be helpful if you give a small example of how to make the browser to make two requests one for image and another for text.