Hello Hassan! :-)

DH>         try
DH>         {
DH>                 File imageFile = new File("./personnel/mfleshman.jpg");
DH>                 if(imageFile.exists() ){ %>

DH> Above code never finds the file.

Well, you could do

  File imageFile = new File( pageContext.getServletContext().
    getRealPath("/images/personell/mfleshman.jpg") );

If you're running tomcat and have tomcat installed
in C:\tomcat
and your current webapp is aaa
then the call will give
C:\tomcat\webapps\aaa\images\personell\mfleshman.jpg
(or something alike)

AFAIK the argument to getRealPath should start with
a "/".

But this won't work on weblogic, even if the app
is deployed in exploded directory format.
getRealPath() always returns null.

Be carefull other: engines may behave the same.

Maybe you could do your check as
<%if ( pageContext.getServletContext().
        getResource("/images/personell/mfleshman.jpg") != null ){%>

Please also note that you were using relative name
"personell/mfleshman.jpg" while all these examples
use an absolute (starting with a "/").

I do not beleive there's a nice way to find out
presence of a resource relative to the current
page, maybe

String path =
 request.getRequestURI().substring(request.getContextPath().length());
if (path.length()=0) path="/";

path = path.substring(0,path.lastIndexOf("/");
path = path + "/";
path = path + "personel/some.gif";

if (servletContext.getResource(path)!=null)

Best regards, Anthony Tagunov

===========================================================================
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