Displaying an image in the jsp page from database.
Joined: Aug 17, 2007
I want to display an image in the JSP page which is retrieved from the database. Do I need to have a getter/setter method in the Managed Bean? If yes, what will be the datatype for that property? If it is not needed, then how can i display that image in my jsp? I have given mycode which i implemented for your reference.
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
// Write image contents to response.
When using this code, I am getting the image alone in the next page. I have to include this image in that jsp page. Please help me how to solve this?
Requests to a web server return a response of a single MIME type. In the event that that MIME type is "text/html", the returned page is expected to contain HTML elements. Some of those elements, such as IMG may contain URL refrerences themselves. In that event, additional requests are made by the browser to resolve those URLs. For the IMG element, that means that the URL should resolve to a MIME type of "image/xxxx", where "xxxx" is the encoding type, such as gif, jpeg or png.
Customer surveys are for companies who didn't pay proper attention to begin with.