I have common css and js files that i include in every jsp file.
So what\'s the best practice to include them in every page ?
I used to use <%@
I like using fragments for this, they are standard supported by JSP so no other dependencies are needed. And as you will see it will comes with lot's of other benefits.
Create a tag (parentpage.tag):
<%@tag description="Base page" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@attribute name="extra_css" fragment="true" %>
<%@attribute name="footer" fragment="true" %>
<%@attribute name="header" fragment="true" %>
....
// insert css that is needed for every page
Then you create individual pages that inherit from this tag
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="t" tagdir="/WEB-INF/tags" %>
// custom css for this page
// footer content
// body content