facebook

File Handling Using Java Web Application(Java Servlet)

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #251709 Reply

    krunalshah
    Member

    Hi,

    My directory structure for my web application is like following

    —Web
    |
    |—-photos
    | |
    | +-abc
    | +-pqr
    |
    |—pages
    | |–home.jsp
    |
    |—WEB-INF
    |
    |-+-classes
    |
    |—src
    |
    |—com
    |
    |—webapp
    |
    |–HomePageAction.java

    Now what I want to do is I have got one Action Servlet from there I want to find out how many directories in web/photos directory.

    Now my first que is when i am using this syntax

    File f1 = new File(path);

    so what shud be the path, shud it be path = “../../photos”;
    but here it cannot find any files. when I am taking the path as path=”../”; then it gives me some files which is not even any directory.

    So I am not sure it is the right way to access the files from web application or servlet. or weather I am taking the wrong path.

    Pls reply me the solution as I am stuck here and dont know what to do.

    Thanks
    Krunal Shah

    #251714

    Riyad Kalla
    Member

    Krunal,
    You will want to use the ServletContext.getRealPath method to resolve the actual path you need, have a look: http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContext.html

    #251719

    krunalshah
    Member

    Riyad,

    Thank you very much

    Krunal

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: File Handling Using Java Web Application(Java Servlet)

You must be logged in to post in the forum log in