General discussion

Locked

How can I get the real path in OS?

By Jason Dong ·
How can I get the real path in JSP or Servlet?

This conversation is currently closed to new comments.

8 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by liujun In reply to How can I get the real pa ...

In JSP you can use sucn as request.getRealPath method.

Collapse -

by Jason Dong In reply to

Thanks for your answer,but I couldn't find the method.

Collapse -

by dongwei In reply to How can I get the real pa ...

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.

Collapse -

by dongwei In reply to

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

Collapse -

by dongwei In reply to

good luck!

Collapse -

by Jason Dong In reply to

Thanks a lot!

Collapse -

by jc2it In reply to How can I get the real pa ...

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

Collapse -

by Jason Dong In reply to How can I get the real pa ...

This question was closed by the author

Back to Web Development Forum
8 total posts (Page 1 of 1)  

Related Discussions

Related Forums