Results 1 to 4 of 4
  1. #1
    newton is offline Member
    Join Date
    Feb 2008
    Posts
    1
    Rep Power
    0

    Default displaying uploaded images on the browser

    Hi ,

    I need help to sort out my problem.I am uploading images into file system
    and storing the location in to database.Then i want to display the uploaded
    images as view in the jsp page using struts2.

    Help me ..

  2. #2
    madhu.forums is offline Member
    Join Date
    Nov 2010
    Posts
    1
    Rep Power
    0

    Default

    Hi,
    please follow the below code snippet,

    import javax.imageio.ImageIO
    import java.awt.image.BufferedImage

    getImageFile {
    BufferedImage bufferedImage = getImageStream(systemFilePath)
    if (bufferedImage) {
    try {
    response.reset()
    OutputStream out = response.getOutputStream()
    ImageIO.write(bufferedImage, 'JPG', out)
    out.flush();
    out.close();
    } catch(Exception ex) {
    ex.printStackTrace();
    }
    }
    }

    BufferedImage getImageStream(String filePath) {
    File imageFile
    BufferedImage bufferedImage
    try {
    imageFile = new File(filePath);
    bufferedImage = ImageIO.read(imageFile)
    } catch(Exception ex) {
    ex.printStackTrace();
    }
    return bufferedImage
    }

  3. #3
    crazysheep is offline Member
    Join Date
    Nov 2010
    Location
    China WhHan
    Posts
    2
    Rep Power
    0

    Default

    why not try to store the img file in a folder and save the url to the database?
    Have you thought about this?

  4. #4
    only_java is offline Member
    Join Date
    Mar 2011
    Posts
    16
    Rep Power
    0

    Default display image

    <img src="<s:url value="/images/sun.jpg"/>" />

    Hope this will help

    :)

Similar Threads

  1. how to display uploaded jpeg in jsp(its urgent)
    By shaktish in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 02-17-2009, 02:52 PM
  2. How to add Images to JPanels?
    By Soda in forum New To Java
    Replies: 3
    Last Post: 12-08-2007, 05:54 PM
  3. Images not displaying in JSP in IE7
    By chadscc in forum Advanced Java
    Replies: 0
    Last Post: 11-13-2007, 03:24 PM
  4. Help with images...
    By toby in forum Java Applets
    Replies: 1
    Last Post: 08-04-2007, 05:25 AM
  5. Images in JSP
    By Daniel in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 06-05-2007, 06:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •