Retrieve « Path « JSP-Servlet Q&A





1. Retrieving the path    coderanch.com

Ok, thanks. So which path do I need to access files in the classpath? The book I have isn't very clear on this point. I added a line in the jsp page to print out what request.getContextPath() returns but it printed nothing. Why does this line in the jsp generates a compiler error(request cannot be resolved): <%! String s = request.getContextPath(); ...

2. How can I retrieve the server path from inside the servlet?    coderanch.com

If you mean access the file using a browser, that all depends on where you have set the "document root" of your server. If you mean access the file from your server-side Java code, that all depends on where the "current directory" is set when you run your server. Or you could, of course, use a full path.