views:

31

answers:

1

All of my JSPs have this at the top:

<%@ page language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="tag" %>

Besides being repetitive, I have had a few hard-to-find bugs because of occasional inconsistencies. For example, a few of my JSP files were missing, isELIgnored="false", causing untold havoc.

Is there any way to put these imports into a file and then import that file in each JSP, rather than listing all of these imports in each file?

+3  A: 

Yes, I always use an include.jsp such as:

<%@ page session="false"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="form" uri="/spring-form" %>
<%@ taglib prefix="spring" uri="/spring" %>   
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>

and then reference that in the page using the import statement:

<%@ include file="/WEB-INF/jsp/include.jsp" %>
karianna
Why do you need `page session = 'false'` in this case?
jts
We've got a RESTFul-like stateless web app, this helps us keep it that way :)
karianna