Discussion Locked
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 liujun
In JSP you can use sucn as request.getRealPath method.
by jason dong
Thanks for your answer,but I couldn't find the method.
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 dongwei
good luck!
by jason dong
Thanks a lot!
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.
by jason dong
This question was closed by the author
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending
Discussion Locked
What Makes a Business Website Effective in 2026
2 helpful
10 replies
1 helpful
3 replies
Question
Windows and macOS computers becoming slow or unstable after updates - what should I check first
0 helpful
1 reply
Question Unanswered
Best Way to Make Long WordPress Location Guides Mobile Friendly
0 helpful
0 replies
Discussion
Optimizing WordPress widgets and DOM size
0 helpful
3 replies