Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include file from dynamic property value

I have a project in Java thgat needs to use;

<%@include file="content.jsp" %>

to include a file into the current jsp page.

However, I now need the content.jsp to be dynamic.

How can I substitute everything in the quotes with a variable?

So;

<%@include file=myVariable %>
like image 879
griegs Avatar asked Feb 14 '11 01:02

griegs


2 Answers

Instead of using static include, you can use dynamic include, then you can do something like this:-

<jsp:include page="<%= myVariable %>" flush="true" />

or

<jsp:include page="${myVariable}" flush="true" />
like image 76
limc Avatar answered Sep 19 '22 19:09

limc


i have work around by using the static include after closing the tag so it still static and can be used as if you assign a string

        <% 

            switch(questionType){

                case 1:%><%@include file="qtypes/yesNo.jspf"%><%
                break; 
                case 5:%><%@include file="qtypes/eval.jspf"%><%
                break; 
                default :%><%@include file="qtypes/yesNo.jspf"%><%
                break; 
            } 

        %>
like image 43
Mahmoud Elsonbati Avatar answered Sep 18 '22 19:09

Mahmoud Elsonbati