• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

include directive doubt

 
John Lincoln
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

the syntax for include is


I tried the following but it does not seem to work
<%String filePath = "/WEB-INF/jsp/test.html";%>

<%@ include file=filePath; %>

Just want to know..if possible

Thanks
 
Rancy Chadha
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,

<%String filePath = "/WEB-INF/jsp/test.html";%>
<%@ include file=filePath; %>

When you run this code what error message do you get? I am not sure of what you are getting but I think you should get message saying 'quotes expected'. The reason is that directive attributes take value in quotes. Instead of putting 'file=filepath' try putting 'file="/WEB-INF/jsp/test.html" it should work. I have tried this and it has worked. Also one more addition, there should not be a ; terminating include directive this also will lead to an exception.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The include directive inserts the text of the specified resource into the page at translation-time. So, the relative URL should be static. In your example, the filePath will be the local variable in your _jspService() method and will be evaluated at request time.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic