File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Please help: jsp include Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Please help: jsp include" Watch "Please help: jsp include" New topic
Author

Please help: jsp include

Jo���o Ronaldo
Greenhorn

Joined: Sep 24, 2003
Posts: 6
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
Nischal Tanna
Ranch Hand

Joined: Aug 19, 2003
Posts: 182
change the <%@ include file=content%>
code to:
<%@ include file=<%=content%> %> n it shall work..


Thnx
Jo���o Ronaldo
Greenhorn

Joined: Sep 24, 2003
Posts: 6
Hi Nischal!
I already tried it too...
and the same error message occurs
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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.


[Jess in Action][AskingGoodQuestions]
Sainudheen Mydeen
Ranch Hand

Joined: Aug 18, 2003
Posts: 218
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60741
    
  65

And don't forget the quote characters.
<%@ include file="content.jsp"%>
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jo���o Ronaldo
Greenhorn

Joined: Sep 24, 2003
Posts: 6
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

Joined: Aug 18, 2003
Posts: 218
Hi
If possible, try to run the file seperately which the string content is pointing to. Is that a JSP file?
----------------
Sainudheen
Sudhakar Reddy
Greenhorn

Joined: Aug 28, 2003
Posts: 9
there should not the % symbol in the <jsp:include...>
correcte one is
<jsp:include page="<%= content %>"/>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please help: jsp include
 
Similar Threads
scanning & deleting unnecessary includes
how to include one html inside another
two questions about struts's template taglib
Difference between WAS 6.0 and its previous versions
How do I get the requested url?