Can anyone suggest how to get the full path in jsp?
I am creating an image anywhere in the java class, and when I try to access this location path in jsp, it does not show the full path.
<html> <head><title>Absolute Path</title></head> Absolute Path is:<%= getServletContext().getRealPath("/") %> </html>
Hope this help helps you.
You can use the real way.
String webRootPath = application.getRealPath("/").replace('\\', '/');
or
String webRootPath = getServletContext().getRealPath("/").replace('\\', '/');
It is better to create a folder of your own resources inside the folder of your application and save all your resources (images in your case).
Then you can access it using this:
String path=application.getRealPath("/resourcesfolder/image.jpg");