How to access the images stored in folder which is kept inside theapplicati

Iam new to java..
I want to display the images (.jpeg,,.gif, flash) which are kept in one folder
Using Jsp...
Its Executing fine in local system..
Its not working 1)when i execute that jsp from other system
2)if i give the full url then only its executing in local system
Please help me...
thanks in advance...
by Priya
<%@ page import="java.io.*"%>
<html>
<head>
<title>Movie Details</title>
</head>
<body text="#000000" bgcolor="#FFFFFF">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#FFFFFF" width="100%" id="AutoNumber1">
<%
File f=new File("..E:\application\Images");
File []f2=f.listFiles();
for(int ii=0;ii<f2.length;ii++)
if(f2[ii].isFile())
String fname=f2[ii].getPath();
%>
<tr>
<td width="87%"><%=fname%> </td>
<td width="14%"><img border="0" src="<%=fname%>" width="150" height="100" ></td>
</tr>
<%
System.out.println(f2[ii].getPath());
%>
</table>
</body>
</html>

Hi,
Well i guess a Simple concept of a image servlet can cater your requirement here.
checkout the below example of how to do it
Configurations needed in /WEB-INF/web.xml:
<servlet>
    <servlet-name>ImageServlet</servlet-name>
    <servlet-class>com.ImageServlet</servlet-class>
    <init-param>
       <param-name>backupFolderPath</param-name>
       <param-value>E:/application/Images</param-name>
       <!--Could use any backup folder Available on your Server and make sure we place a image file named noImage.gif which indicates that there is no file as such-->
    </init-param>
     <load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>DownloadServlet</servlet-name>
    <url-pattern>/Image</url-pattern>
</servlet-mapping>
ImageServlet.java:
package com;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
*@Author RaHuL
/**Image Servlet
*  which could be accessed Image?fid=fileName
*  or
*  http://HOST_NAME:APPLN_PORT/ApplnContext/Image?fid=fileName
public class DownloadServlet extends HttpServlet{
  private static String filePath = new String();
  private static boolean dirExists = false;
  public void init(ServletConfig config){
      // Acquiring Backup Folder Part
      filePath = config.getInitParameter("backupFolderPath");
      dirExists = new File(filePath).exists();      
  private void processAction(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
       // getting fileName which user is requesting for
       String fileName = request.getParameter("fid");
       //Building the filePath
       StringBuffer  tFile = new StringBuffer();
       tFile.append(filePath);    
       tFile.append(fileName); 
       boolean exists = new File(tFile.toString()).exists();
       FileInputStream input = null;
       BufferedOutputStream output = null; 
       int contentLength = 0;
       // Checking whether the file Exists or not      
       if(exists){                  
        try{
            // Getting the Mime-Type
            String contentType = this.getContentType(tFile.toString());          
            input = new FileInputStream(tFile.toString());
            contentLength = input.available();
            response.setContentType(contentType);
            response.setContentLength(contentLength);
             String contentDispo = "";
              try{
                 contentDispo = request.getParameter("coid");
              }catch(Exception exp){
             if(contentDispo != null && contentDispo.equals("69125"))
               response.setHeader("Content-Disposition","attachment;filename=\""+fileName+"\"");       
            this.exportFile(input,response.getOutputStream());
         }catch(Exception exp){
             exp.printStackTrace();
             this.getServletContext().log("Exception Occured:"+exp.getMessage());
             throw new ServletException(exp.getMessage());
       }else{
          try{
             // Getting the Mime-Type
            String contentType = this.getContentType(filePath+"noImage.gif");          
            input = new FileInputStream(filePath+"noImage.gif");
            contentLength = input.available();
            response.setContentType(contentType);
            response.setContentLength(contentLength);
            this.exportFile(input,response.getOutputStream());
          }catch(Exception exp){
             exp.printStackTrace();
             this.getServletContext().log("Exception Occured:"+exp.getMessage());
             throw new ServletException(exp.getMessage());
  /** Gets the appropriate ContentType of the File*/
  private String getContentType(String fileName){
        String url = java.net.URLConnection.guessContentTypeFromName(fileName);
           if(url == null)
             return "application/octet-stream";
           else
             return url;
       or one may use
       return new  javax.activation.MimetypesFileTypeMap().getContentType(fileName);
       NOTE: Do not forget to add activation.jar file in the classpath
  /** Prints the Image Response on the Output Stream*/
  private void exportFile(InputStream input,OutputStream out) throws ServletException,IOException{
         try{
                output = new BufferedOutputStream(out);
                while ( contentLength-- > 0 ) {
                   output.write(input.read());
                output.flush();
          }catch(IOException e) {
                e.printStackTrace();
                 this.getServletContext().log("Exception Occured:"+e.getMessage());
                 throw new IOException(e.getMessage());
          } finally {
               if (output != null) {
                   try {
                      output.close();
                  } catch (IOException ie) {                     
                        ie.printStackTrace();
                     this.getServletContext().log("Exception Occured:"+e.getMessage());
                     throw new IOException(ie.getMessage());
  /** HttpServlet.doGet(request,response) Method*/
  public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{       
        // Calling  respective Action Method to Provide File Service
        this.processAction(request,response); 
  /** HttpServlet.doPost(request,response) Method*/
  public void doGet(HttpServletRequest request,HttpServletResponse response) throws         ServletException,IOException{
        // Calling  respective Action Method to Provide File Service
        this.processAction(request,response); 
NOTE: The following code could be used to provide service to stream any sort of files with any sort of content
with some minor modications.
Inorder to access all the images you can restructure your jsp like the one below
JSP:
<!--
     And say we have are storing Image name & Movie details in the database and we are created a collection
     of all the database results like bean here is how we would display all the details with images
     Say you wrote a query to findout Moviename,timings,Hall Number & pictureFileName
     example:
        Movie: DIE HARD 4.0
        Timings: 10:00AM,2:00PM,9:15PM
        Hall NUmbers: 1,1,2,4 
        pictureFileName: die_hard_4.jpg
         or
        Movie: Transformers
        Timings: 11:20AM,2:20PM,10:15PM
        Hall NUmbers: 2,3,1,5 
        pictureFileName: transformers.jpg
     say you are saving the information in a dtoBean with properties like
      public class MovieBean{
         private String movieName;
         private String timings;
         private String pictureFileName;
         /* and followed by getters & setter of all those*/
      and say we have queried the database and finally collected an ArrayList<MovieBean> from the query results and
      saving it within the scope of session with the attribute name "MovieList"
-->
<%@ page language="java"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<html>
<head>
<title>Movie Details</title>
</head>
<body text="#000000" bgcolor="#FFFFFF">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#FFFFFF" width="100%" id="AutoNumber1">
<thead>
<tr>
    <td>Movie Name</td>
    <td>Timings</td>
    <td>Hall Numbers</td>
    <td>Poster</td>
</tr>
</thead>
<tbody>
<c:forEach var="movieBean" items="${sessionScope.MovieList}">
    <tr>
         <td><c:out value="${movieBean.movieName}"/></td>
         <td><c:out value="${movieBean.timings}"/></td>
         <td><c:out value="${movieBean.hallNo}"/></td>
         <!-- Here is where we are making use of image servlet and trying to retrive images -->
         <td><img src="Image?fid=<c:out value="${movieBean.pictureFileName}"/>" align="center" width="30" height="30"/></td>
    </tr> 
</c:forEach>
</tbody>
</table>
</body>
</html>Hope this might help,If that does do not forget to assign the duke stars which you promised :)
REGARDS,
RaHuL

Similar Messages

  • How to get the image stored in archieve link as an attachment in work item.

    Hi All,
    through transaction OAWD we are storing scanned images.
    Once this transaction is executed a workitem appears in the inbox of the initiator with the scanned invoice as attachment.
    When the user executes the work item FV60 screen is displayed where the user enters the data based on the scanned invoice attachment.
    After the user Parks the document the custom workflow triggers and a workitem appears in the inbox of an approver.
    Our requirement is that the scanned image should also appear as the attachment.
    Can you please suggest how to get the image stored in archieve link as an attachment in work item.
    Regards
    Shraddha

    Hi Martin,
    with every parked document a scanned image is linked.
    I need to create a link under objects and attachments in the work item, such that when the user clicks that link the image is displayed.
    At present the following functionality is available.
    The BO used is FIPP
    Objects and attachments:
    parkeddocument:AK0108500001252008.(via FIPP binding with WIOBJECT_ID)
    On clicking the link below objects and attachments: the parked document AK0108500001252008 opens in display mode.
    Now we want to have 2 links:
    parkeddocument:AK0108500001252008.
    image.
    When we click on the link image then the scanned invoice linked to the document should get opened.
    I am able to get the image id of the the image through  SAP_WAPI_GET__OBJECTS,
    export parameter leading_object provides the detail.
    But I am not able to figure out how to use it in my workflow to display it as an attachment.
    Hope this will give a better understanding of my question.
    can you please suggest as to how I should proceed with it.

  • How to access the data stored in Java tables in E-Commerce 7.0

    For the CRM E-Commerce 7.0 Web shop all the data related order templates, Shop Id and catalog variants are not getting stored in CRM tables. Can anyone please let us know where all the details are getting stored.
    By searching here, in SDN Forum we found that these details are getting stored in some java tables. If this is true  kindly let us know the following points.
    1). How can we access these tables.
    2).Where these java tables are stored .
    3).Do we have authorizations to check and modify these tables.
    4).If we donu2019t have authorizations to check and modify these tables, how can we get the access to them.
    4).How can we write Database Queries to retrieve the data from these tables.

    I am afraid, all these three entities are in CRM tables.
    Web Shops - Function module CRM_ISA_SHOP_GETLIST, Table crmm_isa_shop_h
    Catalog Variants - Function module - COM_PRDCAT_GET_VARIANTS (they are also stored in CRM tables) for a given catalog.
    Now for the Order Templates - They are technically order objects with system status set to "Order Template" I1034. You should be able to see them in CRM tables alongwith other orders... crmd_orderadm_h and etc...

  • How to access the e-mails which are stored in different folders via Mac

    Hi guys, I am new to Mac. My problem is about the setting of Mac Mail.
    There are 8 folders with my hotmail account in order to automatically sort e-mail into folders. I only can get the e-mails of inbox folder via Mac Mail software. I am wondering how to access the other e-mails which are stored in other folders.
    Thanks a lot!

    I don't think that things have changed going from 10.5 Mail to 10.6 Mail in this regard (I need to log on to my laptop more often). So, assuming that my premise is correct, in the left hand column of the mail window, underneath your inbox, drafts, sent, trash, and junk mailboxes, there should be the descriptive name of your mail account, written in gray capital letters, with a gray triangle to the left of that name. If the gray triangle is pointing to the right, click on it so that it points downward. That will expand the account view of mailboxes on the server. You should be able to see all of the other folders.

  • How to get the path of the image stored in DMS

    Hi everyone..
    My question is that I have attached an image with an order through transaction jha2n..
    Now my requirement is to get the image in report..
    I know the Logical id in ISM_l_ord class and physical id in ISM_P_Ord class.
    I know that link between image and order is in SKWG_BREL.
    But i am not able to get the path so that i can show the image in docking control.
    pls help to retrive the path of the image stored...
    Thanks
    Pooja

    EpicMaster wrote:Now the problem is when I run the application through the .jar file in the dist/ directory the images simply wont load...
    ..lblProduct.setIcon(new ImageIcon("Resources.zip/res/Product.png"));
    Now the problem is when I Build&Clean the whole project which creates a /dist directory containing the complied and execulatble .Jar file for the application AND a folder called "lib" which contains the Resource.Zip folderThe String based constructor to ImageIcon presumes the String represents a File path. File objects do not work with resources inside Jar or Zip archives, for those, you need an URL. Gain the URL using something like..
    URL urlToImage = this.getClass().getResource("/res/Product.png");

  • How to get the path of the image stored in sap??

    Hi All
    The problem is
    While making an entry in standard there is a field called documents through which we attach our images in sap.
    How to get the path of the image stored with the corresponding order so that the image can be displayed while we are creating a report.
    I know how to upload the image while creating a report using docking control.
    I am not able to get the path of the image stored...
    Please Help
    Thanks in advance..
    Pooja

    I am not aware of exactly which tables are used for storing the attached doc. details, but we have worked in the similar requiremnent.
    What you can do is .... before uploading the image to any order, try swich on the SQL trace ST05 and after upload switch off.
    The log will display what are the tables involved while storing the image. And you can easily find out the image location.

  • How to display the image which in KM folder using url iview

    Hi Friends
    How to display the image, which is under KM folder structur using the url iview.
    i trying using url iview url as  \document\testfolder\abc.jpg as url for the iview.
    but its now working .. so please help me how to slove this problem
    If is not the correct way then please suggest me best way to achive this.
    Thanks
    Mukesh

    Hi Mukesh,
    I think this may work,
    1, Create a HTML Layout.
        You can put your image wherever  u want with HTML Codes.
        Check this, [Article|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3915a890-0201-0010-4981-ad7b18146f81] & [Help|http://help.sap.com/saphelp_nw04/helpdata/en/cc/00c93e9b2c3d67e10000000a114084/frameset.htm]
        With this, u can use the standard KM commands also.
    2, U need to use KM Navigation iView for this rather than KM Doc iView.
    3, In the Nav iView, u can use &rndLayoutSet=nameOfUrHTMLLayout to force the view with this new layout.
    Regards
    BP

  • How to print the image data stored in object of 'java.io.File' Class in jsp

    I have created a file object for the image file in the system temporary directory.Now I want to display it in my page. please tell,How to print the image data stored in object(in my program it is imgr) of 'java.io.File' Class in jsp

    Create a servlet which gets an InputStream of the file and writes it to the OutputStream of the response and call this servlet in `src` attribute. That's basically all.
    Here's an example which covers the most of the minimum needs: [http://balusc.blogspot.com/2007/04/imageservlet.html].

  • HT4910 sold my ipad today. the concern is how to access all info stored in cloud and if possible eventualy merge data into new andriod tablet. Thanks all of you who respond.

    sold my ipad today. the concern is how to access all info stored in cloud and if possible eventualy merge data into new andriod tablet. Thanks all of you who respond.

    >
    <IfModule mod_weblogic.c>
    WebLogicCluster 127.0.0.1:7005,127.0.0.1:7007,127.0.0.1:7003,127.0.0.1:7103,127.0.0.1:7104
    MatchExpression /app1
    </IfModule>
    <Location /weblogic>
    SetHandler weblogic-handler
    WebLogicCluster 127.0.0.1:7003,127.0.0.1:7005,127.0.0.1:7007,127.0.0.1:7103,127.0.0.1:7104
    DebugConfigInfo ON
    PathTrim /weblogic
    </Location>
    <IfModule mod_weblogic.c>
    WebLogicCluster 127.0.0.1:7003,127.0.0.1:7005,127.0.0.1:7007
    MatchExpression /app2
    </IfModule>
    <Location /weblogic>
    SetHandler weblogic-handler
    WebLogicCluster 127.0.0.1:7003,127.0.0.1:7005,127.0.0.1:7007
    DebugConfigInfo ON
    PathTrim /weblogic
    </Location>
    >
    This configuration is weird little bit. There is MatchExpression /app1 and MatchExpression /app2 and at the same time two <Location /weblogic> sections. Are you sure you understand what that configuration stands for?
    Try something like this ...
    <Location /app1>
    SetHandler weblogic-handler
    WebLogicCluster 127.0.0.1:7003,127.0.0.1:7005,127.0.0.1:7007,127.0.0.1:7103,127.0.0.1:7104
    DebugConfigInfo ON
    </Location>
    <Location /app2>
    SetHandler weblogic-handler
    WebLogicCluster 127.0.0.1:7003,127.0.0.1:7005,127.0.0.1:7007
    DebugConfigInfo ON
    </Location>
    where /app1 and /app2 are contexts of your weblogic applications.
    http://download.oracle.com/docs/cd/E11035_01/wls100/plugins/apache.html
    http://httpd.apache.org/docs/2.0/mod/core.html#location

  • C7 how to access the PRIVATE folder in phone memor...

    C7-00 how to access the PRIVATE folder in phone memory?
    Meaning the folder C:\private
    With X-plore you can see the folder but it is marked as 0 kb.
    Edit: reason for this is that I had Angry Birds installed on memory C:
    Then I had changed my phones default game install memory to E: at the OVI store setup in the phone. On Monday OVI suggested that I should update the AB and so I did.
    Now it installed the new version to memory E: and all my game progress was gone.
    Just need to see if the save game still lays on C:\private\20030e51.
    Solved!
    Go to Solution.

    Ah, I'm sorry - I thought it was the private folder in C drive that I had managed to get into the previous week but it was the private folder in mass storage ...
    If you want to thank someone, just click on the blue star at the bottom of their post

  • How to access the archive folder in jive forums programiticaaly

    hi
    how to access the archive folder in jive forums programitically using weblogic 10.3
    Thanks
    Rani

    Ah, I'm sorry - I thought it was the private folder in C drive that I had managed to get into the previous week but it was the private folder in mass storage ...
    If you want to thank someone, just click on the blue star at the bottom of their post

  • How to access the stored password list of N9 nativ...

    How to access the stored password list of N9 native browser?

    most everything should be listed here.
    there was a way to see the website data and stored information, but not the passwords. they were ************
    you were only able to delete the login information, and unfortunately, since i have not used the device in so long, have forgotten the language.
    so you will have to dig a bit.
    it was a command that you would enter into the browser address bar.
    if it comes to me i will repost, but for now...check here.
    http://talk.maemo.org/showpost.php?p=1104892&postcount=1

  • Accessing the Image folder on the mobil

    Hello
    I want to make an app that sends a form, with the possibility
    to attach an image.
    Is it possible to access the image folder on the
    Mobil?

    quote:
    Originally posted by:
    CHAOS'|nc.
    yep you surely would need python support for that
    . otherwise the file
    restriction issue in devices will catch up and make your progress
    stagnant
    yes, it works...thanks 'CHAOS'|nc
    .' for this!
    Simon G.

  • I am new to ios & using 5C. I want to know where is all the media (Images, videos, Audio etc) received through Whatsapp are saved after downloading in Iphone. And also how to access the same.

    I am new to ios & using 5C. I want to know where is all the media (Images, videos, Audio etc) received through Whatsapp are saved after downloading  in Iphone. And also how to access the same.

    These are user to user forums.  You ARE NOT addressing Apple by posting here.
    Also, why are you YELLING at us??  Stop using ALL CAPS.
    What steps have you done to try and fix the problem?

  • How do i import images stored in a folder sequential​ly and add a timer to change in sequence?

    Hello,
    I am actually very new to Labview and I do not have much idea about it. Can anyone provide me a VI which can import images stored in a folder sequentially.
    Example: the images stored in the folder have names like 1.bmp,2.bmp and so on...
    I want to import 1.bmp first and after 8 seconds 2.bmp and so on..
    Please help me with  this.
    Thanks
    Solved!
    Go to Solution.

    Saved in 2012
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.
    Attachments:
    Display Images 2012.vi ‏10 KB

Maybe you are looking for

  • Sort and filter option missing in table view

    Hi, I am not able to see the sort and filter option for all the columns in table view. Could anyone please help me if i need to add something to see that option. Thanks, Kamesh Bathla

  • Redo Log Groups

    Call me stupid, but for some reason I've decided to get certified as a DBA even though I have always been a developer. Honestly, its not my fault. The choices in the development track are pretty boring... Anyway, while pouring through the Backup/Reco

  • Best way to copy a DVD

    I have a few DVDs that i want to copy. What is the easiest way to do this? Thanks

  • How to synchronize music from my iphone to iTunes on my PC?

    How to synchronize music from my iphone4 to iTunes on my PC? I'm scared of deleting all data from my iphone (music and apps) as my mediathek at iTunes is empty right now. I downloaded all my music directly on my iphone, but now would like to copy it

  • How do I check temperature on my G5?

    I want to know what temperatures everything is running at. How can I check that?