I have a web archive with a file placed in the WEB-INF directory.
How do I load that file in a java class?
I know I can put it in the classes directory and load it from there. It would just be put it in WEB-INF.
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.
Use the
getResourceAsStream()method on the ServletContext object, e.g.How you get a reference to the ServletContext depends on your application… do you want to do it from a Servlet or from a JSP?
EDITED: If you’re inside a Servlet object, then call
getServletContext(). If you’re in JSP, use the predefined variableapplication.