3 Replies Latest reply on Apr 16, 2012 11:15 AM by peterj

    How do dynamically load the images in JBoss AS 7

    sudeep.batra

      Hi,

                 My requirement is that one jsp will be storing the images in one particular folder on my Mac on my home directory (which is fine) and the second jsp has to display the images from this folder. Now since these images are not in the war file, how do i configure the JBoss to be able to display the images. Need to do this urgently so any help will be greatly appreciated.

       

      Regards,

        • 1. Re: How do dynamically load the images in JBoss AS 7
          peterj

          I would do this by defining a system property which you can use to define the directory containing the images. I would write a servlet that uses the directory location and image file name, opens the image file and writes it to the repsonse output. The servlet will also have to change the response mime type to correspond to the image type.

          Search the net for "return image from servlet", there are lots of examples.

          • 2. Re: How do dynamically load the images in JBoss AS 7
            sudeep.batra

            Hi Pete thanks for your quick reply, but won't this be very slow and bad design since my jsp will be calling this servlet several times on the same page...Any other suggestions ? Would creating a different http server or ftp server to server the images help or be faster ?

            • 3. Re: How do dynamically load the images in JBoss AS 7
              peterj

              This is basically the same algorithm that a web server uses to serve images that are within the web app. Your JSP should be writing <img> tags into the HTML output and let the browser request the separate images, usally in parallel. Thus multiple instances of the servlet will be running, each processing a different image request.