i'm building a little site with some subfolders. I dunno in how many subfoler a jsp page will be, so i need a way to know the realpath of my web pplication, in order to do something like this:
<link rel="stylesheet" type="text/css" href="<%=realpath%>/Style.css" >
and not doing this
<link rel="stylesheet" type="text/css" href="../Style.css" >
<link rel="stylesheet" type="text/css" href="../../Style.css" >
<link rel="stylesheet" type="text/css" href="../../../Style.css" >
I used this.
ServletContext context = session.getServletContext();
String path = getServletContext().getRealPath("/");
But it doesn't work, even if the path seems to be right (when i print it on the screen), when i open the jsp page my CSS is not found.