• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

display image in jsp

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 261
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
     
    Rancher
    Posts: 43081
    77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.)
     
    I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
    Smokeless wood heat with a rocket mass heater
    https://woodheat.net
    reply
      Bookmark Topic Watch Topic
    • New Topic