It's easy, you can do the following by using <jsp:invoke />
tag instead of the <include />
tag. It's new for jsp 2.0 and allows you to take some fragments from one page to another, making very easy the task of building templates. You can check a tutorial here.
And this is the way to solve your problem:
Create a tag folder and put this in it.
template.tag
<%@tag description="Main template of the page" pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
<%@attribute name="header" fragment="true" required="false" %>
<html>
<head>
...some css and javasctipt used on all the pages...
<!-- Custom css and javascript for one page -->
<jsp:invoke fragment="header"/>
</head>
<body>
<jsp:doBody />
</body>
</html>
Use the previous template on your page by including the tag folder:
useOfTemplate.jsp
<%@page contentType="text/html" pageEncoding="UTF-8" %>
<%@taglib prefix="custom" tagdir="/WEB-INF/tags" %>
<custom:template>
<jsp:attribute name="header">
...Here you can include your custom css and javascript for this page...
</jsp:attribute>
<jsp:body>
...here comes the info of the page...
</jsp:body>
</custom:template>