How to find the parent directory of a servlet?

Gerrit Goetsch

try this..

to get the URL

java.net.URL url;
try {
  url = new java.net.URL(new java.net.URL(req.getRequestURL ().toString()),"../");
} catch (java.net.MalformedURLException e) {
  // catch the exception ....
}


or this to get the real path

String path = new java.io.File(getServletContext().getRealPath("")).getParent();

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact