How can you know in which directory a JSP file is?

Discussion in 'Java' started by Albretch, Apr 15, 2004.

  1. Albretch

    Albretch Guest

    Say you put the same JSP in

    <%CATALINA_BASE%>/webapps/webappName/Dir00/

    and

    <%CATALINA_BASE%>/webapps/webappName/Dir99/

    How could you make the JSP by itself tell apart 'Dir00' from 'Dir99'?

    None of these work:

    // __
    String aPth = null;
    File Fl;
    try{ Fl = new File("."); aPth = Fl.getCanonicalPath(); }
    catch(IOException IOXcptn) { IOXcptn.printStackTrace(); }
    System.err.println(" new File(".").getCanonicalPath()=" + aPth);

    // __
    aPth = (new File(".")).getAbsolutePath();
    System.err.println(" (new File(".")).getAbsolutePath=" + aPth);

    Is there any work around?
     
    Albretch, Apr 15, 2004
    #1
    1. Advertising

  2. Albretch

    Roedy Green Guest

    On 14 Apr 2004 19:58:24 -0700, (Albretch) wrote or
    quoted :

    > File Fl;
    > try{ Fl = new File("."); aPth = Fl.getCanonicalPath(); }
    > catch(IOException IOXcptn) { IOXcptn.printStackTrace(); }


    You drive people nuts by violating the caps coding conventions.

    Please see http://mindprod.com/jgloss/codingconventions.html

    variables MUST start with a lower case letter.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Apr 15, 2004
    #2
    1. Advertising

  3. Albretch

    Albretch Guest

    I mean, how can you achieve it at once from the JspInit part of the servlet

    You can do it from a request each time by going:

    String aRqPath = request.getServletPath();
    String aAppPath = application.getRealPath(aRqPath);
    String aPath = new File(aAppPath).getParentFile().getPath();
     
    Albretch, Apr 15, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. niksa
    Replies:
    0
    Views:
    1,109
    niksa
    Mar 13, 2005
  2. MD
    Replies:
    3
    Views:
    619
    Mark Rafn
    Oct 24, 2006
  3. Mufasa
    Replies:
    4
    Views:
    354
    Mufasa
    May 1, 2007
  4. Aston J.
    Replies:
    13
    Views:
    665
    Justin Collins
    Mar 16, 2011
  5. Andries

    I know, I know, I don't know

    Andries, Apr 23, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    281
    Gregory Toomey
    Apr 23, 2004
Loading...

Share This Page