Sort of, yes.
boolean condition = evaluateItSomehow();
request.setAttribute("condition", condition);
request.getRequestDispatcher("/WEB-INF/page.jsp").forward(request, response);
Then in page.jsp
using JSTL c:if
:
<head>
<c:if test="${condition}">
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="script.js"></script>
</c:if>
...
</head>
Update: since you seem to have more than one files for this, you can even make it more flexible by just setting the desired filename suffix (or prefix, or even the entire name, what you like):
String suffix = evaluateItSomehow();
request.setAttribute("suffix", suffix);
request.getRequestDispatcher("/WEB-INF/page.jsp").forward(request, response);
and
<head>
<link rel="stylesheet" type="text/css" href="style_${suffix}.css">
<script type="text/javascript" src="script_${suffix}.js"></script>
...
</head>
If you set suffix
to for example "foo"
, this will load style_foo.css
and script_foo.js
. I think this gives enough new insights.