• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Upload Image in a JSP Page

 
Natasha Sirat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,

I need some advice on Image Upload in JSP's. I am currently working on an application where I have the image data available to me in a Byte[].

We are using the following packages to implement Image Upload:
org.apache.struts.action.*
org.apache.struts.upload.FormFile

The FormFile object is converted into a byte[] by using the getFileData() method.

After the user selects the image to be uploaded and clicks OK:

1) We need to display the image in the same browser window in a thumbnail view.
2) We need to display this image on the next page also after the user submits his POST operation.

Currently I was trying to read about memorystreams in order to convert this image byte[] in to a image format to be dispalyed on the webbrowser.

We are using JSP, Pageflow, Weblogic 8.1 to develop this application.

Also we need to display this image from the memory first. As the image will be saved on the remote server only after the user chooses to publeh the AD untill such time we want to display the image in the browser window.

That is the reason I was thinking about MemoryStreams().

Do let me know what is the best way to handle images.

Thank you very much

Natasha
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Natasha S,
Welcome to JavaRanch!

We're pleased to have you here with us in the JSP forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

You can change it here
[ January 20, 2006: Message edited by: Ben Souther ]
 
Natasha Sirat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure...Thank you for letting me know...

Natasha
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember that JSP are for character output - images are binary data which can NOT be served correctly in a character stream. Your JSP must write an IMG tag in the HTML output where the src refers to a servlet that can format the correct response for the image request. This topic comes up frequently, browse around in recent posts.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic