What is the equivalent of PHP's $_SERVER['DOCUMENT_ROOT'] in Java?

You can use ServletContext.getContextPath() to get context path or use ServletContext. GetRealPath(String path) to get real path for a given virtual path.

I am not using servet. I am using Jersey to return the url. – tribal Oct 4 at 7:32.

The simplest way if you not use servlet API is to create File object point to the . /: System.out. Println(new File(".

/").getAbsolutePath()); In this case you should see in console path to your application directory. This could be your $_SERVER'DOCUMENT_ROOT' for this application.

I need the returned path to be "localhost:8080/mypics/pic1. Jpg"; when the server is localhost and "mysite. Com/mypics/pic1.

Jpg"; when running on a live server. The new File(". /") code is not working; the ServletContext.getContextPath() returns not found.

– tribal Oct 4 at 17:30.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions