Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get full path in jsp?

Tags:

java

jsp

Can anyone please suggest how to get full path in jsp?

Iam creating an image in some location in java class, and when im trying to access this location path in jsp, it is not showing the full path.

like image 222
Vidya Sagar Avatar asked Aug 21 '12 14:08

Vidya Sagar


2 Answers

<html>
<head><title>Absolute Path</title></head>
Absolute Path is:<%= getServletContext().getRealPath("/") %> 
</html>

Hope this help you

like image 148
sasikals26 Avatar answered Nov 09 '22 03:11

sasikals26


You can use real path.

 String webRootPath = application.getRealPath("/").replace('\\', '/');

or

   String webRootPath = getServletContext().getRealPath("/").replace('\\', '/');
like image 28
amicngh Avatar answered Nov 09 '22 03:11

amicngh