• Post Reply Bookmark Topic Watch Topic
  • New Topic

Relative file paths in JSP

 
Puneet Agarwal
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JSP which is including a static HTML page. Both the JSP and the static HTMl are in the same directory. The static HTML has references to .js and .html file inside it. These .js and .html files are also in the same directory as static HTMl and JSP.

The scenario is as below.I am adding relevant snippets from the files

JSP: <jsp:include page= '<%=text%>' />.The name of static HTML is dynamic

Static HTML: <script type="text/javascript" src="book.js"></script>
<link rel="stylesheet" type="text/css" href="styles/styles.css">

The problem is that the JSP is not finding the .css , .html and .js files. It is trying to find the files at the application context directory.
I dont want to specify the full paths(from the context in HTML).

Is there a way I can make the JSP read the .js , .css,.html files in this scenario.
 
Adrian Enns
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use the request.getContextPath() method?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!