aspose file tools*
The moose likes JSP and the fly likes Upload Image in a JSP Page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Upload Image in a JSP Page" Watch "Upload Image in a JSP Page" New topic
Author

Upload Image in a JSP Page

Natasha Sirat
Greenhorn

Joined: Jan 20, 2006
Posts: 2
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

Joined: Dec 11, 2004
Posts: 13410

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 ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Natasha Sirat
Greenhorn

Joined: Jan 20, 2006
Posts: 2
Sure...Thank you for letting me know...

Natasha
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12823
    
    5
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
 
 
subject: Upload Image in a JSP Page