I need to get the web container path using java, is there any method for that? I need to use it using JSP or Servlet to get a file path.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
So the file is stored in the public webcontent of the WAR? Use
ServletContext#getRealPath().Note that this only works when the WAR is expanded by the container. Otherwise better use
ServletContext#getResourceAsStream()if all you really want is to get anInputStreamof it.See also: