Barcode Image display in email/jsp

Hi,
I want to display the barcode image in the email/jsp.
I have created one droplet. This will generate the barcode image and will return as a OutputStream.
I am trying to convert this OutputStream as a byte array and setting in a request param. When i access this param in the jsp and trying to display as a image using dsp:valueof or dsp:img tag, i am getting only the byte array whatever i have set in the droplet instead of image.
I have set the content type as image/jpeg also in the request object.
I have tried to write the converted byte array in a response object also and accessed the droplet in jsp.
But i am not getting the image in the jsp. I am getting only the byte array in the jsp.
Please suggest me any other solution to resolve this.
Thanks,
Saravanan

If you have a binary array for image, you can try to use a servlet for rendering the image directly from the byte array. Doing it through a separate servlet would ensure that we do not run into the issue of mixing character and binary based response streams. Here is the pseudo code for doing this.
In Servlet:
BarcodeImageHandlerServlet extends extends HttpServletService {
public void service(HttpServletRequest request, HttpServletResponse response)  throws ServletException, IOException {
  byte [] imageByteArr = getImage(); //your image byte array
  String name= "barcode-01";
  response.setContentType("image/jpeg");
  response.setContentLength(imageByteArr.length);
  response.setHeader("Content-Disposition", "inline; filename=\"" + name + "\"");
  BufferedInputStream input = null;
  BufferedOutputStream output = null;
  try {
    input = new BufferedInputStream(new ByteArrayInputStream(imageByteArr));
    output = new BufferedOutputStream(response.getOutputStream());
    output.write(imageByteArr);
  catch (IOException e) {
  finally {
    if (output != null) {
      try {
        output.close();
      catch (IOException iex) {
    if (input != null) {
      try {
        input.close();
      catch (IOException iex) {
}Create following component configurations in your application's config layer to add your servlet using ServletPathServlet and ServletPathDispatcher:
/atg/myapp/BarcodeImageServlet.properties:
$class=com.myapp.BarcodeImageHandlerServlet
$scope=global
/atg/dynamo/servlet/pipeline/ServletPathDispatcher.properties:
dispatcherServiceMap+=\
/barcode-image-servlet\=/atg/myapp/BarcodeImageServlet
/atg/dynamo/servlet/pipeline/ServletPathServlet.properties:
servletPaths+=/barcode-image-servlet
Then in your JSP you can call it as:
<img src="<c:out value="${pageContext.request.contextPath}"/>/dyn/barcode-image-servlet" />

Similar Messages

  • Image displays in some jsp files but not others

    OK, I have a jsf jsp pages js tag for my application that occurs in several jsp pages:
    <tr>
       <td>
          <jsp:include page="/includes/footer.jsp"/>
       </td>
    </tr>     footer.jsp has an image tag like this:
    <td align="left"><img src="images/logo.jpg" alt="X Systems"/></td>     The jsp files are in a directory which is under the base directory like the include and image files. For some reason, in one jsp page the logo.jpg file does not get displayed. As I understand it, the application server jboss/tomcat resolves the image files. Why would it be displayed it in one page and not another?

    You are using a relative link to access your image.
    That means it will look for your image relative to the page it last served.
    If you ask for http://myapp/root.jsp, it will locate http://myapp/images/logo.jsp
    If you ask for http://myapp/module/index.jsp it will locate http://myapp/module/images/logo.jsp
    If you right click on your image / broken image placeholder and look at its properties, you should be able to see the url which it is trying to fetch the image from.
    The client will resolve relative links from the address url it last accessed. It knows nothing of any serverside forwards/includes that you might have done.
    So if you access http://myapp/action and forward to /moduel/accounting/balanceSheet.jsp it will still treat the url as http://myapp/action for resolving relative links.
    As far as the client is concerned, the root is /
    As far as your web application is concerned, the root is /myapp (or whatever your context name is)
    Because of this you can't give your images an static absolute url, because you would be hardcoding the context name into your jsp.
    Alternatives
    - use something like <img src="<%= request.getContextName() %>/images/logo.jsp"/>
    - use a tag library to hide the implementation of option #1 (like struts tag html:img)
    - only use relative links, and always specify a html <base> on your page to resolve relative links from.
    Hope this helps,
    evnafets

  • IOS5 ms-exchange incorrect images displayed in email

    Hi, not sure what to do about this, any help would be great.
    We have a number of iPhones in our office and are experiencing problems with inline attachments when viewing emails on iPhones with iOS5 installed.
    Scenario:
    Many emails sent from our service desk to staff, the email is always sent from the same account and contains text and images in html format. After opening one of these on a device with ios5 installed the images that were part of that email will be displayed in any other email that is openened.
    This can be replicated on iOS5 on iPhone4 and 4S in the office
    This did not occur previously, and still does not happen on iphones that remain on iOS4

    yet another bug in iOS 5.0.1!!!!!!

  • Remote images displayed in email

    Hello! Despite the fact that I have "Display remote images in HTML messages" unchecked, about half the time Mail.app displays the image anyway. Has anyone else experienced this, and have you found a cure? I tried searching the forum, but the only hits I came up with were how to make Mail display remote images, not how to prevent it from doing so.
    I've tried checking "Display remote images...", closing Mail, reopening Mail, and unchecking "Display remote images..." (thinking it would force a rewrite to the preferences file), but there was no change in behaviour. I also tried moving com.apple.mail.plist out of the way so that a new one was created, but that confused Mail so much that I couldn't open all my old emails so I moved it back. If there is an easy way to recreate com.apple.mail.plist and not lose access to my old emails, I'll try that....
    Cheers!
    G4 400 MHz AGP (Sawtooth)   Mac OS X (10.4)   768 MiB

    Declan,
    I am seeing index files leftover from both Jaguar and Panther periods of use. These can often be problematic, and in this case might explain some random behaviors.
    Because your mailboxes, or at least some of them, originated in Panther, and earlier, I want you to read the article at the link below:
    http://docs.info.apple.com/article.html?artnum=301315
    This issue of leftover files applies not only to mailboxes you have previously created (which are in the Mailboxes folder the article mentioned) but can also apply to those mailboxes in account folders created prior to the upgrade to Tiger.
    Also, please check the size of any remaining mbox files in each folder. It is very important to compare the size of any file named "mbox" with that of the Messages folder. If the mbox is greater in size than the Messages folder, then it means that not all messages were converted to be in the Messages folder. This would likely be most important for any On My Mac mailboxes, as you must have been able to determine most message content was converted.
    You should see several benefits from this cleanup.
    Ernie

  • Display the images in excel using jsp

    Hi
    I am unable to display the images in excel using jsp. I can display the data. but cannot display the images. It is simply showing the icon without the image. Is there any way to display the images. Pls give some sample code to display the images in excel.
    Thanks in advance.

    Presumably whoever created the images in that Excel document just put links to somewhere on their hard drive. Those links don't mean anything when you put the document on somebody else's computer, which is what you are doing. At least, that is my guess.
    You could spend some time looking at the Excel file to see how the images were put in there. Or you could ask the person who put the images in there.

  • Problem in Retrieve Image from DB and display in the JSP page

    Hi All,
    I did one JSP Program for retriveing image from DB and display in the JSP Page. But when i run this i m getting "String Value" output. Here i have given my Program and the output. Please any one help to this issue.
    Database Used : MS Access
    DSN Name : image
    Table Name: image
    Image Format: bmp
    Output : 1973956
    Sample Program:_
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.io.*" %>
    <%
         try{
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Connection conn = DriverManager.getConnection("jdbc:odbc:image");
              Statement st = conn.createStatement();
              ResultSet rs = st.executeQuery("SELECT images FROM image");
              String imgLen="";
              if(rs.next()){
                   imgLen = rs.getString(1);
                   out.println(imgLen.length());
              if(rs.next()){
                   int len = imgLen.length();
                   byte [] rb = new byte[len];
                   InputStream readImg = rs.getBinaryStream(1);
                   int index=readImg.read(rb, 0, len);
                   System.out.println("index"+index);
                   st.close();
                   response.reset();
                   response.setContentType("image/jpg");
                   response.getOutputStream().write(rb,0,len);
                   response.getOutputStream().flush();
         }catch(Exception ee){
              out.println(ee);
    %>
    Thanks,
    Senthilkumar S

    vishruta wrote:
    <%
    %>Using scriptlets is asking for trouble. Java code belongs in Java classes. Use a Servlet.
                   out.println(imgLen.length());Your JSP was supposed to write an image to the output and you wrote some irrelevant strings to the output before? This will corrupt the image. It's like opening the image in a text editor and adding some characters before to it.
                   byte [] rb = new byte[len];Memory hogging. Don't do that.
              out.println(ee);You should be throwing exceptions and at least printing its trace, not sending its toString() to the output.
    You may find this article useful to get an idea how this kind of stuff ought to work: [http://balusc.blogspot.com/2007/04/imageservlet.html].

  • I tried to display gif image from oracle to jsp but nothing appear

    i tried to display image from oracle DB to jsp directly without using file processing , and i used Servlet and jsp , Servlet to get image from DB and jsp to use <img> tag , when i Run Servlet code
    the image appaer on Microsoft Photo Editor , and when i run jsp the image dose not appear on jsp page , so please anyone has an idea about this broblem ,send the soluation or any information to my e-mail [email protected] , and I'll thankful about your help.
    the Servlet and jsp code are below .
    thank for your help
    Servlet:
    import java.io.InputStream;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.PrintWriter;
    import java.io.IOException;
    public class Servlet extends HttpServlet
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    response.setContentType("image/gif");
    int id = Integer.parseInt(request.getParameter("no"));
    // int id = 2 ; when Run Servlet .
    ResultSet rs = null;
    Connection Lcon = null;
    String stmt = " select Image from ImageTable where lmage_id ="+id;
    Statement sm = null;
    String data1 ="";
    try
    Lcon = getConntcion();
    sm = Lcon.createStatement();
    rs = sm.executeQuery(stmt);
    if(rs.next())
    InputStream in = rs.getBinaryStream(1);
    ServletOutputStream sout = response.getOutputStream();
    int c;
    while((c=in.read())!= -1)
    sout.write(c);
    in.close();
    sout.flush();
    sout.close()
    }catch(Exception e)
    System.out.println("error in selectValue the error is "+e);
    finally
    rs .close( );
    sm .close( );
    Lcon.close( );
    public Connection getConntcion()
    Connection con = null;
    try{
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    con = DriverManager.getConnection(",,,,,,,, DB Info ,username and password ,,,,,,,,,,,");
    }catch(Exception e)
    System.out.println("error in connection the error is "+e);
    return con;
    Jsp code :
    <%@ page contentType="text/html"%>
    <html>
    <head
    </head>
    <title> testing image </title>
    <body>
    <form>
    <img src="servlet/Servlet?no=2">
    </form>
    </body>
    </html>

    InputStream in = rs.getBinaryStream(1);
    byte[] image= null;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    byte[] buffer = new byte[8192];
    int bytesRead = 0;
    while ((bytesRead = in.read(buffer, 0, 8192)) != -1)
         baos.write(buffer, 0, bytesRead);
    image= baos.toByteArray();
    in.close();
    ServletOutputStream sout = response.getOutputStream();
    if (image != null)
           sout.write(image);
           sout.flush();
    }

  • Image/content cannot be display in email after ISO 7

    Image/content cannot be displayed in email for iPhone 4 after update ISO 7

    Gary,
    Thanks so much for your help!
    The facebook link is now working for the client...unfortunately the Paypal link does not.
    After testing it on other Windows machines with no problems, I am starting to speculate that it is something unique to her setup. I'll have to keep testing I guess and see if any other errors come up.
    Thanks again Gary for the very helpful suggestion that solved at least one of my problems!

  • Imbeded jpeg and jpg images don't display in email. It works when I use the Chrome browser. I'm running att.yahoo. mail. I have reset firefox, also reinstalled.

    I tried recommendations that I understood in this forum to no avail. I tried resetting Firefox. Then I uninstalled and reinstalled. It still doesn't work. It used to work all the time. Now it works once in a great while. Instead of showing as an image in the email it shows as an attachment at the top of the email with the option of slideshow. If you click on the picture it sometimes will appear, more often than not it will not. It works every time when using the Chrome browser.

    If images are missing then check that you aren't blocking images from some domains.
    *Press the F10 key or tap the Alt key to bring up the hidden "Menu Bar" temporarily.
    *Check the permissions for the domain in the currently selected tab in "Tools > Page Info > Permissions"
    *Check "Tools > Page Info > Media" for blocked images
    *Select the first image link and use the cursor Down key to scroll through the list.
    *If an image in the list is grayed and "<i>Block Images from...</i>" has a check-mark then remove this check-mark to unblock images from this domain.
    Make sure that you do not block (third-party) images, the permissions.default.image pref on the <b>about:config</b> page should be 1.
    Make sure that you haven't enabled a High Contrast theme in the Windows/Mac Accessibility settings.
    Make sure that you allow pages to choose their own colors.
    *Tools > Options > Content : Fonts & Colors > Colors : [X] "Allow pages to choose their own colors, instead of my selections above"
    Note that these settings affect background images.
    See also:
    *http://kb.mozillazine.org/Website_colors_are_wrong
    There are extensions like Adblock Plus (Firefox/Tools > Add-ons > Extensions) and security software (firewall, anti-virus) that can block images and other content.
    See also:
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    *http://kb.mozillazine.org/Images_or_animations_do_not_load
    *http://kb.mozillazine.org/Websites_look_wrong

  • When I attach images to an email they show as the image and not an icon.  Is there a way to make the attachment an icon?

    When I attach images to an email they show as an image and not an icon.  Is there a way to have them attached as an icon?
    When I send attachments this way some people can't save them.   They can see them but not save them.
    Any ideas?

    They are received as attachments, i.e. icons. What you see is the real image on your disk, and only if small enough to be displayed. Otherwise, they are small icons inserted in the text.
    Additionally, when you place an image in the message, you will find an option in the lower right corner, otherwise absent. Use it, if need be.

  • Image in a email body without attachment

    Hi Gurus,
       I have requirement wherein i need to send an image in body of email.As of now i am able to create attachment and refer it to body of the email .this works fine and the image displays in body of the email.
       The problem is when i send the mail to outlook it works fine, but when i send to others for e.g. gmail or lotus note, no image comes in the body , only image comes as an attachment.
       can some expert solve this problem.
    Or if some can help in sending the image in the body of the email without attachment is also fine?
    Regards,
    Madhu

    Madhu,
    Can you post the steps you took to get the html to goto the body when it is sent to an Outlook account?  Even this is an impressive feat.  Did you put the html into a Smartform and somehow get it to render in the e-mail body?  Please explain.
    -Ken

  • How to display photo in jsp through blob from oracle

    i am struggling here to retrieve an image which is stored in oracle-blob data type through jdbc-type-1.and i am unable to display that in jsp.i had a rich code library for this problem.but nothing gave me the exact solution.
    please give me exact the solution..
    pls ...

    What have you tried?
    What happened?

  • Missing images in distributon email

    I have created my form and distributed it through the Distribute Form. I sent the form to a couple of people in my department to test the form. In the email they receive, there appears to be missing images above and below the text I entered in the distribute form. The end user only sees the typical red outline with a small x in the corner indicating there should be an image. The email is sent via Lotus Notes email system.
    How do I display the image and where is it generated from?

    Hi,
    That is nothing to do with the form.
    You are distributing the form via Acrobat.com - which is perfectly fine.
    The red x is from the email client blocking the standard Acrobat.com header and footer:
    Clicking the download pictures, which show the images:
    Just note that these have nothing to do with the form itself.
    Niall

  • Dynamic image display Problem

    Hi
    I am trying to display images in 2 ways static and dynamic
    unfortunately the dynamic display the last 2 doesn't show
    anything
    <mx:Image height="35" width="35" styleName="MediumIcon"
    visible="{r.currentItem.extramedicine=='true'?true:false}"
    source="@Embed('images/icon_extra-medicine.gif')"/> ->
    Display Image
    <mx:Image height="35" width="35" source="@Embed
    ('{r.currentItem.mood}')"/> -> Don't display image
    <mx:Image height="35" width="35" source="@Embed
    (source='{r.currentItem.mood}')"/> -> Don't display
    image
    mordsm

    "mordsm" <[email protected]> wrote in
    message
    news:gl6nqm$sso$[email protected]..
    > Hi
    >
    > I am trying to display images in 2 ways static and
    dynamic
    > unfortunately the dynamic display the last 2 doesn't
    show anything
    >
    >
    > <mx:Image height="35" width="35"
    styleName="MediumIcon"
    >
    visible="{r.currentItem.extramedicine=='true'?true:false}"
    > source="@Embed('images/icon_extra-medicine.gif')"/>
    -> Display Image
    >
    > <mx:Image height="35" width="35" source="@Embed
    > ('{r.currentItem.mood}')"/> -> Don't display image
    >
    > <mx:Image height="35" width="35" source="@Embed
    > (source='{r.currentItem.mood}')"/> -> Don't
    display image
    >
    When you use @Embed the image is...embedded. That means it is
    compiled into
    the file, when it's not running. The compiler has _no_ idea
    what the value
    of your variable is expected to be at runtime.
    Try
    <mx:Image height="35" width="35"
    source="{r.currentItem.mood}"/>
    HTH;
    Amy

  • Html newsletters displayed in Email

    This seems like an easy topic but it is not to be found in
    these forums. I contantly get emails that display an html page when
    opened. They are linked to the sender's site to get the images. I'm
    on a Mac, how do I make my email newsletter display in emails my
    clients get? I have the newsletter up on a server now ready to
    download but how do I get the viewers email program to download and
    display it automatically? I'd rather they don't have to click on a
    link to see it.

    1. Upload all of your cotent to the site.
    2. navigate to that page.
    3. click ctrl +A to select the entire page.
    4. now click ctrl + c to copy the page.
    5. now paste it into your email and your done.
    Note: Make sure your images have the full url reference to
    them. You can do this quickly with the find/replace function.
    So your images should go from:
    /images/imagename.jpg
    to
    http://www.yoursitename.com/images/imagename.jpg

Maybe you are looking for

  • One year warranty coverage is almost over, should I get Applecare?

    Just wondering what you all thought about spending another 249 bucks for three years of coverage...my Macbook is running smoothly, knock on wood, but down the road, who knows.... battery... screen... motherboard.... Superdrive.... case... Are there a

  • How can I get Lightroom CC to open on my Windows 7 desktop?

    Creative Cloud says Lr Cc is installed but it will not open.

  • Payment not accepted how can I resolve this?

    Would like to purchase coins but unable to process payment what do I do?

  • IMail

    I'm using an IMail server in my company. I have an application which sends email using the Java Mail API. When I send to a user whose registered in the IMail system, the mail get's sent fine. The problem is that I need to be able to send email to use

  • Why does the iTunes cache become so big?

    My computer keeps on running out of space on the hard disc.  I finally figured out that it is from the iTunes cache folder being more than 200gbs!  Why???  I deleted it and got everything working again.  Just out of curiousity I checked again a coupl