what will be the mime type for java application if I want to show both image and html content?
In my java web application i need to show the image that exits in the database as well as a anchor tag for moving to another jsp page.
In my jsp page it is mentioned response.setContentType("image/jpg;");
So while running the jsp page is shows the image but do not show the html below or anywhere.
开发者_Go百科What i want that my jsp page should show the image as well as html content at a single jsp page. So please tell what mime type should i use
so that to get desire result.
Thank you,
Your problem is twofold. First, you send a HTML-page that contains the IMG-tag with the appropriate reference to the source image. Of course this can be surrounded by an A-tag. That page should be of text/html
.
Secondly, you return the image. This is a separate call to the server. That call should be of image/jpg
.
Mime types in HTML headers are intended to help browser distinguish between types of binary content transferred from the server. So, if you transfer just HTML, you should specify text/html. You should use image/jpg only if you transfer image binary data to browser using this page.
<input type="image" src="./ShowImage">
This will help to show the image as it pass it to the servlet that have the code for displaying image.
And below the above code you write any html code which also can be seen at the same single jsp page.
精彩评论