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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

barcode display in JSP

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi,

i have to display a barcode image in JSP.

MY requirements are:

1. When page is loading barcode should be rendered based on some parameters passed.
2. JSP rendering is in diff module.
3. I have to write a utility method, which creates barcode image and returns image.

My questions are:

1. How to call a java class method from src attribute of <IMG> tag.
2. I have a class which uses iText to create barcodes for pdf document. I can reuse the same method which returns java.awt.Image.

Is my approach right? or there is a better way of acheiving this easily.

regards
strive
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
You didn't mention a servlet. You want to be following MVC and have a servlet call your Java code putting valid values in the request attributes. Then the JSP can use EL to grab those request attributes.
 
Sheriff
Posts: 67746
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:
  • Report post to moderator
Your src attribute should address a servlet that uses your utility class to create the image data which it then streams as the response.

There a number of examples in earlier posts that show how to do this.
 
Mahesh Rud
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Thanks for the responses

I am able to do that.
 
Bear Bibeault
Sheriff
Posts: 67746
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:
  • Report post to moderator
As you started another post for this issue, I'm closing this topic.
    Bookmark Topic Watch Topic
  • New Topic