10

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.

Matt Ball
  • 354,903
  • 100
  • 647
  • 710

3 Answers3

8

The jsp-property-group was introduced in JSP 2.0 (i.o.w. Servlet 2.4). Websphere 6.0 is Servlet 2.3.

So you have 3 options:

  1. Forget it.
  2. Upgrade Websphere.
  3. Replace Websphere.
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 2
    We might be upgrading websphere, but we will never replace it for the same reason it was chosen to develop on in the first place. I used to like IBM products until I started using WID/WAS. –  Nov 08 '09 at 12:50
5

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.

skaffman
  • 398,947
  • 96
  • 818
  • 769
  • I second this. Either SiteMesh or Tiles. – amischiefr Aug 06 '09 at 18:39
  • I've used SiteMesh before and like it; however, we're using Tiles. I wanted to just simplify the JSP so it was fewer lines of code, striped down to the meaningful part. –  Aug 07 '09 at 14:50
1

You could try writing a Filter that calls

getRequestDispatch( "path-to-jsp-to-include" ).include( req, res )
sth
  • 222,467
  • 53
  • 283
  • 367