• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Please help: jsp include

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
change the <%@ include file=content%>
code to:
<%@ include file=<%=content%> %> n it shall work..
 
Jo���o Ronaldo
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nischal!
I already tried it too...
and the same error message occurs
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And don't forget the quote characters.
<%@ include file="content.jsp"%>
bear
 
Jo���o Ronaldo
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I tried to use <jsp:include page="<%= content %>"/%>
But I got another error messaged:
org.apache.jasper.JasperException: /index.jsp(14,0) /window.jsp(23,38) Unterminated
 
Sainudheen Mydeen
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
If possible, try to run the file seperately which the string content is pointing to. Is that a JSP file?
----------------
Sainudheen
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there should not the % symbol in the <jsp:include...>
correcte one is
<jsp:include page="<%= content %>"/>
 
Bras cause cancer. And tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic