java - Passing a set of parameters to jsp include using jstl -
i'm having trouble this, , google wasn't helpful on particular subject.
i have following want execute:
<c:foreach var="block" items="${blocks}"> <jsp:include page="${block.blockjsp}"/ </c:foreach>
the idea behind have set of "blocks". allows me create page in modular fashion. works fine, , i'm happy way works.
now want customize content of blocks passing few key/value pairs while page being created:
<c:foreach var="block" items="${blocks}"> <jsp:include page="${block.blockjsp}"> <c:foreach var="blockparam" items="${block.blockparameters}"> <jsp:param name="${blockparam.key}" value="${blockparam.value}"/> </c:foreach> </jsp:include> </c:foreach>
this gives me nasty jasperexception:
org.apache.jasper.jasperexception: /jsp/survey.jsp (line: 113, column: 24) expecting "jsp:param" standard action "name" , "value" attributes @ org.apache.jasper.compiler.defaulterrorhandler.jsperror(defaulterrorhandler.java:42) @ org.apache.jasper.compiler.errordispatcher.dispatch(errordispatcher.java:443) @ org.apache.jasper.compiler.errordispatcher.jsperror(errordispatcher.java:89) @ org.apache.jasper.compiler.parser.parseparam(parser.java:809) @ org.apache.jasper.compiler.parser.parsebody(parser.java:1655) @ org.apache.jasper.compiler.parser.parseoptionalbody(parser.java:986) @ org.apache.jasper.compiler.parser.parseinclude(parser.java:838) @ org.apache.jasper.compiler.parser.parsestandardaction(parser.java:1100) @ org.apache.jasper.compiler.parser.parseelements(parser.java:1434) @ org.apache.jasper.compiler.parser.parsebody(parser.java:1647) @ org.apache.jasper.compiler.parser.parseoptionalbody(parser.java:986) @ org.apache.jasper.compiler.parser.parsecustomtag(parser.java:1258) @ org.apache.jasper.compiler.parser.parseelements(parser.java:1435) @ org.apache.jasper.compiler.parser.parse(parser.java:138) @ org.apache.jasper.compiler.parsercontroller.doparse(parsercontroller.java:242) @ org.apache.jasper.compiler.parsercontroller.parse(parsercontroller.java:102) @ org.apache.jasper.compiler.compiler.generatejava(compiler.java:199) @ org.apache.jasper.compiler.compiler.compile(compiler.java:374) @ org.apache.jasper.compiler.compiler.compile(compiler.java:354) @ org.apache.jasper.compiler.compiler.compile(compiler.java:341) @ org.apache.jasper.jspcompilationcontext.compile(jspcompilationcontext.java:657) @ org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:357) @ org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:395) @ org.apache.jasper.servlet.jspservlet.service(jspservlet.java:339) @ javax.servlet.http.httpservlet.service(httpservlet.java:727) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:303) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208) @ org.apache.catalina.core.applicationdispatcher.invoke(applicationdispatcher.java:748) @ org.apache.catalina.core.applicationdispatcher.processrequest(applicationdispatcher.java:486) @ org.apache.catalina.core.applicationdispatcher.doforward(applicationdispatcher.java:411) @ org.apache.catalina.core.applicationdispatcher.forward(applicationdispatcher.java:338) @ com.narran.survey.surveyservlet.showsurvey(surveyservlet.java:45) @ com.narran.survey.surveyservlet.doget(surveyservlet.java:27) @ javax.servlet.http.httpservlet.service(httpservlet.java:620) @ javax.servlet.http.httpservlet.service(httpservlet.java:727) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:303) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:220) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:122) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:503) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:170) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:103) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:116) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:421) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1070) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:611) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:314) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61) @ java.lang.thread.run(unknown source)
perhaps limited understanding of jstl preventing me fixing issue. setting correctly?
i don't know how blockjsps like, suggest workaround :
<c:foreach var="block" items="${blocks}"> <c:set var="blockparams" value="${block.blockparameters}" scope="request" /> <jsp:include page="${block.blockjsp}" /> </c:foreach>
this set collection blockparams
available in requestscope, therefore accessible within .jsp corresponding block - treat collection inside jsp, variable instead of parameter.
Comments
Post a Comment