Title: RE: Wrong ordering of rendered html elements when using templates under WAS 3.5.x

All right amiable people,

I've found what's been causing me grief. It's sucky servlet engines that's what it is.


From J2EE 1.2.1 specs API documentation:

javax.servlet.jsp
  Class PageContext

public abstract void include(java.lang.String relativeUrlPath)
  throws ServletException,
  java.io.IOException

[...]
The current JspWriter "out" for this JSP is flushed as a side-effect of this call, prior to processing the include.
[...]


So go figure - if you issue pageContext.getOut().flush(); before pageContext.include(…) and it will work as advertised...

I believe that WebFear is using an old JSP Servlet container implementation that just "forgot" to implement this piece of the spec. however, my problem can be fixed WITHOUT any code changes - I have to do two things:

1. put no code (other then <template:include … />) in home.jsp
2. use <template:get flush="true" … />

I hope others will learn from my misfortune. Thanks for other for chipping in with advice. Fare well,


Nik
--
Nik Malenovic <mailto:[EMAIL PROTECTED]>

-----Original Message-----
From: Nik Malenovic [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 30, 2001 7:00 PM
To: [EMAIL PROTECTED]
Subject: Wrong ordering of rendered html elements when using templates under WAS 3.5.x


Hello personable people,
We've got a live one over here - using templates under WebSphere 3.5.4 (don't ask) with struts 1.0 (plus a fix or two that is required to get struts functioning properly under WAS3.5.x) produces misordered rendered html elements.


Here's what I mean:
Actors:
-------
Home.jsp
Home_content.jsp
Home_template.jsp
Home.jsp:
---------
[<%@ taglibs here %> ]
<!-- home.jsp:My Title -->
<template:insert template="home_template.jsp">
  <template:put name="title" direct="true">My Title</template:put>
  <template:put name="content" content="home_content.jsp" />
</template:insert>
Home_content.jsp:
------------------
[<%@ taglibs here %> ]
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>foo</td>
  </tr>
</table>
Home_template.jsp
------------------
[<%@ taglibs here %> ]
<html:html locale="true">
  <head>
    <title><template:get name="title" /> </title>
  </head>
  <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" height="24">
      <tr>
        SOME MORE WILD TEXT HERE
      </tr>
    </table>
    <!-- begin content -->
    <template:get name="content" />
    <!-- end content -->
  </body>
</html:html>



Output of glorious home.jsp hosted by WAS3.5.x (notice out of order rendering!):
-----------------------------------------------------------------------------
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>foo</td>
  </tr>
</table>
<html lang="en">
  <head>
    <title>
      My Title
   </title>
  </head>
  <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" height="24">
      <tr>
        SOME MORE WILD TEXT HERE
      </tr>
    </table>
    <!-- begin content -->
   
    <!-- end content -->
  </body>
</html>




<!-- home.jsp:My Title -->



See the problem? :-) I'd appreciate anyone with a clue to send me one.


Thanks,


Nik
--
Nik Malenovic <mailto:[EMAIL PROTECTED]>

Reply via email to