Say if all request for images will refer to the same action like
image.do, then
So map this to a particular action.
Set the content type and write the image content to the ServletOutputStream
return null for ActionForward.
The snippet below should give you an idea.
Consider if resource.getResource() returns a byte[] - (Some how you
should be able to get a byte[] for the image stored in DB.)
If image is of type gif or jpg/jpeg - then you can do something like
what is shown below.
String imgType = gif or jpg/jpeg // for understanding.
String contentType = "image/";
if(imgType.equalsIgnoreCase("gif")){
contentType+="gif";
}else if(imgType.equalsIgnoreCase("jpg")){
contentType+="jpeg";
}else {
contentType = "text/html";
}
response.setContentType(contentType);
ServletOutputStream outStream = response.getOutputStream();
outStream.write(resources.getResource());
outStream.flush();
return null;
Thanks,
Vijay Venkataraman
[EMAIL PROTECTED] wrote:
Hi All,
My application saves the images in database as BLOB. I now want to
display these images stored in my database. How can I do this in struts
2.0 ?
Thanks & Regards
Prerna
The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain proprietary, confidential or privileged information. If you are not the
intended recipient, you should not disseminate, distribute or copy this e-mail.
Please notify the sender immediately and destroy all copies of this message and
any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should
check this email and any attachments for the presence of viruses. The company
accepts no liability for any damage caused by any virus transmitted by this
email.
www.wipro.com
------------------------------DISCLAIMER------------------------------
This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission.
If you receive this message in error, please immediately delete it and
all copies of it from your system, destroy any hard copies of it and
notify the sender. You must not, directly or indirectly, use, disclose,
distribute, print, or copy any part of this message if you are not the
intended recipient.
Lisle Technology Partners Pvt. Ltd. and any of its subsidiaries each
reserve the right to monitor all e-mail communications through its
networks.
Any views expressed in this message are those of the
individual sender, except where the message states otherwise and the
sender is authorized to state them to be the views of any such entity.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]