I would like to simplify my JSP's even further by transparently including them. For instance, this is the line I would like to remove:
<%@ include file="/jsp/common/include.jsp"%>
The include.jsp file basically declares all the tag libraries I am using. I am running this on WebSphere 6.0.2 I believe and have already tried this configuration:
<!-- Include this for every JSP page so we can strip an extra line from the JSP -->
<jsp-config>
<jsp-property-group>
<url-pattern>*.htm</url-pattern>
<!--<include-prelude>/jsp/common/include.jsp</include-prelude>-->
<include-coda>/jsp/common/include.jsp</include-coda>
</jsp-property-group>
</jsp-config>
Both the include-prelude
and include-coda
did not work.
I was reading that other WebSphere users were not able to get this up and running; however, tomcat users were able to.
The jsp-property-group
was introduced in JSP 2.0 (iow Servlet 2.4). Websphere 6.0 is Servlet 2.3.
So you have 3 options:
I'm not sure which version of the Servlet spec this was introduced... is it possible that Websphere's servlet container doesn't support it?
Either way, for this sort of task there's a much nicer 3rd-party tool called SiteMesh . It allows you to compose pages in exactly the sort of way you describe, but in a very flexible way. Recommended.
您可以尝试编写一个调用的过滤器
getRequestDispatch( "path-to-jsp-to-include" ).include( req, res )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.