• Post Reply Bookmark Topic Watch Topic
  • New Topic

display image in jsp

 
Abhishek Reddy
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi every one,

I have a table for with employee details and his photo. I have an employee persistance object with data. Now i have to display the data in a table.

I can able to display all data except image. Image is in the form of byte array. how to display this byte array as image along with other details.

thanks in advance
-Abhishek
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so given that:
  • A JSP is merely a template to create an HTML page.
  • HTML has no way of using a byte array to create an image.
  • HTML does have a simple way of including an image.


  • You should be able to see the problem with your approach.

    So what's the correct approach?
     
    Abhishek Reddy
    Ranch Hand
    Posts: 259
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    thanks for the reply,

    iam using jsp for displaying data.

    used jstl core tags for iterating through the list and displaying the same in the jsp
     
    Ulf Dittmer
    Rancher
    Posts: 42970
    73
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The simple way of adding an image that Bear alluded to is the <img> tag. The JSP would add that tag along with whatever other text information you want to display.

    What's left to think about is what URL you would use in the image tag so that the appropriate image can be loaded. It could be something like "http://myserver.com/myApp/imageServlet?id=12345678", and "imageServlet" would be mapped to a servlet that retrieves the image data and streams back the image to the browser. (The CodeBarn actually has an example servlet that streams an image to the client.)
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!