Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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: 67651
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: 43028
    76
    • 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.)
     
    reply
      Bookmark Topic Watch Topic
    • New Topic