Hi Richard,

I tried to use the java.io.File.exists() method, but doing the following.
        try
        {
                File imageFile = new File("./personnel/mfleshman.jpg");

                if(imageFile.exists() ){ %>
                file exists.
                <table><tr><td>
                        <img src="personnel/Eid.jpg">
                ......
                ......
        }catch()....

Above code never finds the file.  And now you have mentioned about
ServletContext.getRealPath() method so I am thinking that my path
which I have given for the file is not correct /unrecognized by java .

Could you please give me an example or please explain more about
ServletContext.getRealPath() method.

thanks much
Hassan




-----Original Message-----
From: Richard Yee [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 15, 2001 4:59 PM
To: [EMAIL PROTECTED]
Subject: Re: checking if there is a file that exists


Hassan,
Use the java.io.File.exists() method.  You will also probably have to use
the ServletContext.getRealPath() method to construct the path to the actual
image file.

As a suggestion, I wouldn't recommend putting the images in the jsp
directory.  They should be put in a separate directory.  If you want to
hide them from the public, put them under the WEB-INF directory and have
them be returned by a servlet or else store them as BLOBs in the DB.

Regards,

Richard


At 05:29 PM 11/15/2001 -0400, you wrote:
>My application needs to display pictures of each employee on employee's
>detail page.
>On this page, all the information about employee is coming from database
>except his picture.
>The image files (pictures) are saved where jsp pages are located.
>The picture names are stored as <employee-id>_<last-name>.jpg
>
>So before displaying the picture on the page I would like to check if the
>photo exists in the image directory.
>
>does anyone has done anything like that.
>Please give some suggestions.
>
>Thanks
>Hassan
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to