tags:

views:

115

answers:

1

Hi All : I have a request which contains parameters and response will give barcode image. We are using Comergent frame work.

<img src="../direct/bestbuy?cmd=BBFBGenerateBarCode&type=code128&msg=12345&fmt=JPEG&height=10&hrsize=5pt" alt="Barcode" width="166" height="44">

The above will go the controller "BBFBGenerateBarCode" and execute the corresponding java class "BarCodeGenerator.java" which will create barcode image and return image in response.

Problem i am facing is, i need to display this image in two things. One is Print page and another in email. If i use the above code in Print.jsp, the request get processed and goes to BarCodeGenerator.java class(i have used system.out.println() in BarCodeGenerator.java) and create image and displaying in printpage But if i use the above image tag in confirmemail.jsp(will send email to user), request is not processing and i cant able to see the image in mail. Please help me.

A: 

This may seem like an elementary issue, and I apologize if you have already discovered that this isn't the problem, but if you are using the literal path of ../direct/bestbuy?cmd=BBFBGenerateBarCode&type=code128&msg=12345&fmt=JPEG&height=10&hrsize=5pt in your email, you will never get an image from that, at least from a desktop email client.

What you want to be doing, is prefixing it with the server name/path. Assuming that mydomain.com is the domain name you are using, you will want to update your email content to have the following image tag:

<img src="http://mydomain.com/direct/bestbuy?cmd=BBFBGenerateBarCode&amp;type=code128&amp;msg=12345&amp;fmt=JPEG&amp;height=10&amp;hrsize=5pt" alt="Barcode" width="166" height="44">

This also assumes correct pathing to the /direct/bestbuy servlet/jsp/etc.

Jordan S. Jones
Hi.. I have used correct server name/path, but it is not processing the request.
Another simple question, are you outputting the correct content type? "Content-Type: image/jpeg"?
Jordan S. Jones
Yeah. If any problem with content type means it wont work in Print.jsp right?. In that jsp page, its showing the image but in mail its not showing i.e. not processing the request..
I'm not sure if this provides any additional benefit, but just today I was debugging some server communication using Fiddler and noticed 2 of my images returned with a content type of text/plain, but still rendered as images in the browser. My only assumption on this one, is that the browser is able to determine what to do with that content based on how it was being called, e.g. <img /> tag. However, most desktop email client's don't, or may not, have the same rendering smarts as a browser.
Jordan S. Jones
Additionally, I would recommend using Fiddler to see what the actual communication between your email client and the server looks like. In doing so, you can ensure that the server is sending the proper mime-type or if the server is throwing an error and is returning the text.
Jordan S. Jones