Bookmark Topic Watch Topic
  • New Topic

barcode display in JSP

 
Mahesh Rud
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65518
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Report post to moderator
Thanks for the responses

I am able to do that.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65518
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
As you started another post for this issue, I'm closing this topic.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!