aspose file tools*
The moose likes JSF and the fly likes Auto display uploaded image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Auto display uploaded image" Watch "Auto display uploaded image" New topic
Author

Auto display uploaded image

MohamedAhmed Ibrahim
Greenhorn

Joined: Jul 21, 2005
Posts: 17
I am using JSF2 and Tomcat 7
I want to upload an image and display it in the same page as a thumbnail how can i do it ?
I tried using primefaces it uploads the image but it never display it till i refresh the application because i upload it to the root of the application.
Thank you for your help
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15662
    
  15

I hope that when you say "upload to the root of the application", you do not mean that you're uploading the image into the WAR directory. You should never write files into a WAR. Or into any of the directories belonging to your webapp server. Always upload into a directory that's external to your server and applications.

To get an image to upload and display, you have to re-render the part of the page that the image is displayed in. If PrimeFaces is using AJAX to manage its file upload, that means that you'll need to have to add AJAX support for re-rendering.

I'm not familiar with Primefaces, so I can't supply details, but it's usually not difficult.


Customer surveys are for companies who didn't pay proper attention to begin with.
MohamedAhmed Ibrahim
Greenhorn

Joined: Jul 21, 2005
Posts: 17
Thank you Tim ,
Do you know any way of using ajax in such situation?
I tried to upload the images to another directory but i failed to make the server know the path of the image . I am using tomcat 7
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15662
    
  15

The server neither knows nor cares about uploaded files. Only your application does.

I'm afraid that my knowledge on image display via AJAX isn't going to be of much use. I've been using RichFaces for that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Auto display uploaded image
 
Similar Threads
Image
Displaying image blob in jsp using image tag
how to upload and retrive a image from mysql database
image uploading and selection an image from many images?
Upload Image in a JSP Page