Method to set the absolute path of jsp files

  • 2020-09-16 07:44:55
  • OfStack

 
<% 
String path = request.getContextPath(); 
String basePath = request.getScheme() + "://" 
+ request.getServerName() + ":" + request.getServerPort() 
+ path + "/";// Return to the form http://localhost:8080/upload/ 
> 

Call:
 
<%=basePath%> 

It can also be used directly in the js code

Related articles: