This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Hi, I have a jsp file created to be a template. This template includes (by the jsp include tag) a file using an String variable called content. It follows: <%@ include file=content%> But when I run it, an error occurs: org.apache.jasper.JasperException: /index.jsp(10,0) /window.jsp(23,22) quote symbol expected Someone Knows how to solve it? Thanks! Joao
I believe the file name has to be a string constant. Think about it: the actual include-ing is done before the JSP is translated into Java code, so obviously it happens long before the Java code is actually run. Therefore, you can't use "include" to compute different behaviors. Depending on what you need to do, you might instead simply use an if-then statement with the contents of the different includes as the alternatives, or forward the incoming request to other JSPs based on the runtime requirements.
Hi <%@ include file="xyz.html" %> is called static inclusion. Here "xyz.html" can not be an expression. The following is invalid. <% String content = "xyz.html"; %> <%@ include file="<%= content %>" %> // invalid You have to use the Dynamic inclusion <jsp:include page="<%= content %>" /%> //valid Thanks Sainudheen