AGE
AGE

Reputation: 3792

Including JSP code from another JSP file correctly

I am a bit fresh to JSP and I am having problems understanding what could be wrong with the following include code within my JSP:

../test-project/main.jsp

<jsp:include page="../blueprint-project/header-includes.jsp"/>
<!-- More HTML/CSS code below which is working and not blocking -->

../blueprint-project/header-include.jsp

<%@ taglib uri="struts-sslext" prefix="sslext" %>
<%@ page import="mts.psp.web.struts.util.WebSessionUtil" %>
<%@ page import="mts.psp.web.struts.util.ActionUtil" %>
<%@ page import="mts.psp.metrics.entity.TestGroup" %>
<%@ page import="mts.psp.util.common.ConfigUtil" %>
<%@ taglib uri="struts-tiles" prefix="tiles" %>
<%@ taglib uri="struts-html" prefix="html" %>
<%@ taglib uri="struts-logic" prefix="logic" %>
<%@ taglib uri="struts-bean" prefix="bean" %>
<%@ taglib uri="jstl-core" prefix="c" %>

The code in header-include.jsp previously existed within main.jsp at the top of the page. What I am trying to do is take this code, put it in another .jsp file (named header-include.jsp) and have it dynamically included into main.jsp

When I attempt to do this, I get a 500 error. Is what I am attempting to do possible/correct at all? Any help from the community would be outstanding.

Upvotes: 1

Views: 815

Answers (1)

AGE
AGE

Reputation: 3792

It seems all I had to do was to use a static include, as suggested in the comments:

<%@ include file="../blueprint-project/header-includes.jsp" %>

Static include allowed me to add the content of header-includes.jsp at translation time into the current page. This is clearly evidenced in the oracle docs as well as this stack overflow answer.

Upvotes: 1

Related Questions