Reputation: 8056
I was developing my toy project using jetty maven plugin and executing goal jetty:run
. Now i decided to check how it works on tomcat.
I have two jspf fragments: header.jspf
and footer.jspf
inside of WEB-INF/jspf/
containing common code for all of my jsp pages. I include fragments like this:
<jsp:include page="WEB-INF/jspf/header.jspf" flush="true">
<jsp:param name="pageTitle" value="Customer registration"/>
</jsp:include>
Jetty processed them like dynamic fragments, while tomcat processed them as static text, that's why i can see:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
in the beginning of web page in my browser. The issue with tomcat was solved easily by renaming: *.jspf into *.jsp. The question is: why different servlet containers act differently? I performed tests on tomcat 8/9 and jetty 9.3.7.
Upvotes: 0
Views: 390
Reputation: 10400
Add a new file extension to mywebapp/WEB-INF/web.xml file. Why do Tomcat does not do this default I don't know. Defaults are in conf/web.xml file you could edit it as well. Another servlet engine may use different servlet name so this is Tomcat only solution.
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
<url-pattern>*.jspf</url-pattern>
</servlet-mapping>
Upvotes: 2