<%@include file='file.jsp' %> dinâmico

1 resposta
Savio

Senhores, tenho que fazer um controle de layout usando includes.
Estou fazendo assim:

<%if (session.getAttribute("origemLogon").equals("1")) {%>
	<%@include file='file1.jsp' %>	
<%} else if(session.getAttribute("origemLogon").equals("2")){%>
        <%@include file='file2.jsp' %>
<%} %>

como não tem como fazer o seguinte controle:

<%@include file='file${origemLogon}.jsp' %>

estava pensando em fazer uma taglibrary onde é montada um include na tela. Assim:

public class IncludeMenu extends TagSupport{
	private static final long serialVersionUID = 1L;
	public int doStartTag() throws JspException {
		try {
			String codParceiro = pageContext.getRequest().getParameter("origemLogon");
			JspWriter out = pageContext.getOut();
			out.println("<%@include file='file.jsp' %>");
			return SKIP_BODY;
		} catch (Exception e) {
			throw new JspException(e);
		}
	}

}

mas em vez de mostrar o conteúdo do include ele mostra na tela a tag include pelo fato de eu estar usando o JspWriter.

Existe alguma forma de inserir um include sem o JspWriter???

1 Resposta

Savio

Galera, a tag

<jsp:include page="file.jsp" />

resolve o meu problema, pois, consigo realizar o controle com EL.

Criado 14 de outubro de 2008
Ultima resposta 14 de out. de 2008
Respostas 1
Participantes 1