Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Upload Image in a JSP Page

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure...Thank you for letting me know...

Natasha
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic