views:

448

answers:

3

Hi all,

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.

Please advise.

Thanks, Walter

+4  A: 

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
I second this. Either SiteMesh or Tiles.
amischiefr
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.
+1  A: 

You could try writing a Filter that calls

getRequestDispatch( "path-to-jsp-to-include" ).include( req, res )
Darryl Stoflet
+3  A: 

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
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.