• 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

include directive with dynamic attribute file

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, currently I'm wrestling with the following problem. I want to include a certain file in a JSP and I'm receiving the filename to be included from the request as a parameter.
This is my code so far.
<%-- Include dynamical path settings --%>
<% java.lang.String envJsp=request.getParameter("envJsp");%>
<%@ include file="<%=envJsp%>" %>
<%-- End Include dynamical path settings --%>
This results in the following error:
org.apache.jasper.JasperException: Bad file argument to include
void org.apache.jasper.compiler.JspParseEventListener.handleDirective(java.lang.String, org.apache.jasper.compiler.Mark, org.apache.jasper.compiler.Mark, java.util.Hashtable)
void org.apache.jasper.compiler.DelegatingListener.handleDirective(java.lang.String, org.apache.jasper.compiler.Mark, org.apache.jasper.compiler.Mark, java.util.Hashtable)
boolean org.apache.jasper.compiler.Parser$Directive.accept(org.apache.jasper.compiler.ParseEventListener, org.apache.jasper.compiler.JspReader, org.apache.jasper.compiler.Parser)
void org.apache.jasper.compiler.Parser.parse(java.lang.String, java.lang.Class [])
void org.apache.jasper.compiler.Parser.parse(java.lang.String)
void org.apache.jasper.compiler.Parser.parse()
boolean org.apache.jasper.compiler.Compiler.compile()
Has anyone experience with this, or isnt it possible ate all perhaps???
All suggestions are more than welcom.
Greeetins, Johan
Posts: 67637
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
This is not possible with the include directive. The directive gets evalauted when the servlet for the JSP is being constructed -- long before the Java code on the page gets executed.
You can use a variable path with the <jsp:include/> tag, which gets evaluated at run time.
Look! It's Leonardo da Vinci! And he brought a tiny ad!
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic