Discussion Locked

How can I get the real path in OS?

0 helpful
8 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How can I get the real path in JSP or Servlet?

8 replies

by dongwei

You can invoke the method getRealPath(String path) which in the class javax.servlet.ServletContext.

For example,you can code like this in your jsp:

<%
String realPath = application.getRealPath(request.getRequestURI);
System.out.println("realPath-->" + realPath + "<--");
%>

In fact the object application in jsp is the ServerContext in servlet.

by dongwei

In jsp/servlet containers a jsp is been compiled a servlet,so you can use the same way in both jsp and servlet.

by jc2it

You are probably better off using a relative path in the long run. It will make your software more flexible and user friendly.

This discussion is closed to new replies.