Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2008
    Posts
    1
    Rep Power
    0

    Default Dynamic image loading in jsp

    Hi,
    I need to load the dynamic images in jsp, where images are stroing outside the application server not part of deployment, images are placed on some folder in linux server.
    I will get the path of the image from the database and i need to fetch the images from the mentioned path and load the images in jsp using custom tags.

    Thanks for the solution in advance.

    Thanks,
    Ramakrishna K M

  2. #2
    roots's Avatar
    roots is offline Moderator
    Join Date
    Jan 2008
    Location
    Dallas
    Posts
    293
    Rep Power
    7

    Default

    As the result what will your JSP serve .. Image Binary data or HTML code for image and someway you will put that remote Image to public accessible place. Please clear on this ..
    dont worry newbie, we got you covered.

  3. #3
    PortalTeam is offline Member
    Join Date
    Jan 2008
    Posts
    5
    Rep Power
    0

    Default

    U have mentioned that u could get the physical path of images from database.
    Then there's no problem get the path into a string in the jsp page using scriptlet and have and img tag give the src of img tag to the String which v point to the path from the db.
    All the best

  4. #4
    roots's Avatar
    roots is offline Moderator
    Join Date
    Jan 2008
    Location
    Dallas
    Posts
    293
    Rep Power
    7

    Default

    You have two options:

    1. In some cache/temp directory (which must be accessible to web server) write the image file from database. And serve the url of that page to the client. This might be inefficient though. You cant get image path if the image is stored binary in database instead of just a link to some directory.

    2. You might have seen capcha, these are live rendering and surely you can do with JSP as well. Tags doesnot play any role here. What you can do is define one JSP/Servlet that renders the live image.
    For example your image is associated with PK xyz then you can pass argument XYZ to that servlet ?image=XYZ in path. That servlet should set content type to MIME type of jpeg or what ever the encoder you are using. Then you can encode directly to the response stream. Do some research on OTN (Oracle) as well they (Their Application Server) use to support these things directly.

    Hope it should help you a bit..
    dont worry newbie, we got you covered.

  5. #5
    Joydeep is offline Member
    Join Date
    Jun 2008
    Posts
    1
    Rep Power
    0

    Default Hi everybody !!!!

    Hi,I have just joined in this forum.

    Saying just Hi to you all. :)

  6. #6
    pmaitra is offline Member
    Join Date
    Oct 2011
    Posts
    1
    Rep Power
    0

    Default Re: Dynamic image loading in jsp

    Hello there,

    I tried using the above code to refresh an image in my webpage. It does not work. It loads the image only once and stays put. Am I doing something wrong? Could someone kindly help me?

    Thanks.

    Java Code:
    <!DOCTYPE html>
    <%@ page import="java.util.*" %>
    <%@ page import="java.util.Calendar" %>
    <%@ page import="java.io.File" %>
    <%@ page import="java.io.*" %>
    <%@ page language="java" import="java.util.*"%> 
    
    <HTML>
    
    <head> 
    </head> 
    
    <BODY>
    
    <img src="C:\\WebDev\\uploads\\image\\image.jpg" border="1" name="track">
    <script language="JavaScript" type="text/javascript">
    function refreshImage(){
      image = "C:\\WebDev\\uploads\\image\\image.jpg"
      document.images["track"].src = image;
      System.out.println("Cycle\n");
      setTimeout("refreshImage()", 5000);
    }
    refreshImage();
    </script>
    
    </BODY>
    </HTML>
    Some insight:
    There will be an image, say image.jpg at a fixed location in the server. It will be overwritten by another program over and over again. I want the webpage to keep loading that same image again and again so that the client can see the progress. I have managed to refresh the page automatically, but that is not what I want to do. I just want the image to refresh.

Similar Threads

  1. Loading Image from local directory
    By nancyhung in forum Advanced Java
    Replies: 0
    Last Post: 01-29-2008, 03:46 PM
  2. Loading An Image Help Please!
    By shaungoater in forum Java 2D
    Replies: 2
    Last Post: 01-09-2008, 08:14 AM
  3. Replies: 0
    Last Post: 01-08-2008, 05:29 PM
  4. how to generate dynamic pdf
    By valery in forum Advanced Java
    Replies: 1
    Last Post: 08-06-2007, 10:01 PM
  5. problems when loading an image in servlet
    By oregon in forum Java Servlet
    Replies: 1
    Last Post: 08-05-2007, 06:02 PM

Posting Permissions

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