Results 1 to 5 of 5
- 12-28-2007, 06:52 AM #1
Member
- Join Date
- Dec 2007
- Posts
- 1
- Rep Power
- 0
how to display uploaded jpeg in jsp(its urgent)
hi all,
i am upload image(jpeg) using FormFile.........
then i am trying to display it but it display the bytes only....
my code is as below....
jsp.
<html:form action="/viewImage.do" method="post" enctype="multipart/form-data">
<table cellpadding="0" cellspacing="0" border="0" summary="Image table">
<tr>
<td align="right">Image </td>
<td align="left">
<html:file property="image" />
</td>
</tr>
<tr>
<td align="center" colspan="2">
<html:submit property="saveImage">Upload Image</html:submit>
</td>
</tr>
</table>
</html:form>
------------------------my action is
public void disImage(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
CompanyImageForm companyImageForm = (CompanyImageForm)form;
FormFile myFile = companyImageForm.getImage();
String contentType = myFile.getContentType();
String fileName = myFile.getFileName();
int fileSize = myFile.getFileSize();
byte[] fileData = myFile.getFileData();
InputStream in = new ByteArrayInputStream(fileData);
BufferedImage image=javax.imageio.ImageIO.read(in);
response.setContentType(contentType);
OutputStream sos = response.getOutputStream();
ImageIO.write(image,"jpeg",sos);
}
thanks,
shaktish
- 01-23-2009, 11:04 AM #2
Member
- Join Date
- Jan 2009
- Posts
- 1
- Rep Power
- 0
Hi I joined today only.
- 01-23-2009, 01:37 PM #3
Member
- Join Date
- Jan 2009
- Location
- Bangalore
- Posts
- 4
- Rep Power
- 0
You need to user the image tag available
<html:img alt="" src="img/modif.jpg" height="" />
and you should be giving the image location for the attribute src
- 01-23-2009, 04:05 PM #4
Yes, you need to take the bytes from the JPEG file and stream them out to a file in a directory on your Web server. In your JSP, create an image tag pointing to the file you just created.
- 02-17-2009, 02:52 PM #5
Member
- Join Date
- Feb 2009
- Location
- Delhi
- Posts
- 63
- Rep Power
- 0
Similar Threads
-
displaying uploaded images on the browser
By newton in forum Web FrameworksReplies: 3Last Post: 03-31-2011, 10:56 AM -
Hi, need some urgent help!
By jdark in forum New To JavaReplies: 2Last Post: 04-18-2008, 06:50 AM -
please help urgent
By ananas7777 in forum AWT / SwingReplies: 2Last Post: 12-25-2007, 08:30 AM -
need urgent help...
By SCS17 in forum New To JavaReplies: 1Last Post: 11-13-2007, 07:52 AM -
Simplest way to read and display a jpeg image
By Hasan in forum New To JavaReplies: 1Last Post: 05-31-2007, 03:42 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks