This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am trying to display an image that is stored in database, on a JSP page. The image gets displayed on whole page but I want to display it in a small area as the JSP page has other elements too.Following is an excerpt from my JSP code, where "image" is the byte array having bytes of image extracted from database.
JSP is merely a templating mechanism for creating HTML pages to send to the browser. Once the response gets to the browser it's just an HTML page like any other. The browser has no knowledge of whether the page came from a JSP, or if you hand-coded it, and treats the page the same as any other HTML page.
So if you were writing this HTML page yourself, would you put the raw data of the image in the src attribute of the <img> tag? Really?
How would you write the tag? Whichever way you would do it by hand is the same way your JSP needs to do it.
So with that in mind, how do you solve your problem?