Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By makpandian

Thread: JSP/Servlet getting root directory

  1. #1
    Java Tip's Avatar
    Java Tip is offline Moderator
    Join Date
    Nov 2007
    Posts
    1,694
    Blog Entries
    430
    Rep Power
    13

    Default JSP/Servlet getting root directory

    Sometimes you wish to get root directory from JSP/Servlet to perform certain operations. Its just a single line of code.

    JSP:
    Java Code:
    String path = application.getRealPath("/");
    Servlet:
    Java Code:
    String path = getServletContext.getRealPath("/");

  2. #2
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    450
    Rep Power
    10

Similar Threads

  1. Listing file system from root directory
    By Java Tip in forum Java Tip
    Replies: 1
    Last Post: 04-18-2009, 11:03 AM
  2. Find nth root of a number
    By perito in forum New To Java
    Replies: 1
    Last Post: 03-03-2008, 07:51 AM
  3. Root Finder for polynomials
    By gibsonrocker800 in forum Advanced Java
    Replies: 11
    Last Post: 01-04-2008, 12:26 AM
  4. Replies: 1
    Last Post: 08-07-2007, 04:47 PM
  5. Context Root change
    By rvasu_77 in forum Advanced Java
    Replies: 2
    Last Post: 07-12-2007, 11:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •