Page truncation (Sitemesh 3, Tomcat 8)

226 views
Skip to first unread message

Corrado Alesso

unread,
Nov 5, 2014, 8:44:52 PM11/5/14
to sitemesh3-users
Hello all,

I am experiencing a problem while porting my app from Tomcat 7 to Tomcat 8.

The app is unchanged and the configuration of Tomcat is stock for both the versions.

The problem manifests itself as a page truncation for html pages served by Sitemesh. The truncation occurs, for some reasons, at 3181 bytes.

Other resources served statically by the default servlet are not truncated. The decorator page, and the fragment page, when accessed with Sitemesh disabled, are not truncated.

So this seems like a problem with Sitemesh or with its interaction with Tomcat 8. As I said, my same app running (in production) on Tomcat 7 is doing just fine.

Anyone experienced the problem, or has any idea/pointer where to investigate?

Thanks, regards
Corrado

Corrado Alesso

unread,
Nov 5, 2014, 8:45:25 PM11/5/14
to sitemesh3-users

Corrado Alesso

unread,
Apr 9, 2015, 2:58:13 AM4/9/15
to sitemes...@googlegroups.com, Kevin Loverde
Thanks Kevin, that's great.

I didn't post any follow up because we were using Sitemesh only for the website (the app is a single page app), and in the end we went through a website redesign which didn't justified the use of a decorator anymore.

But if you want or need to bounce some thoughts on the issue, feel free to ping!

2015-04-08 23:16 GMT+02:00 Kevin Loverde <klov...@gmail.com>:
I have this exact problem. I'm working on it now, if I figure anything out, I will let you know.

Kevin Loverde

unread,
Apr 9, 2015, 7:33:37 AM4/9/15
to sitemes...@googlegroups.com, co.a...@fastwebnet.it
I have this exact problem. I'm working on it now, if I figure anything out, I will let you know.

On Wednesday, November 5, 2014 at 8:44:52 PM UTC-5, Corrado Alesso wrote:

Kevin Loverde

unread,
Apr 9, 2015, 11:55:23 AM4/9/15
to sitemes...@googlegroups.com, co.a...@fastwebnet.it
Sitemesh 3 has this as a bug in their GitHub page:


I've found 2 ways around it so far. Rename *.html files to *.jsp. This will make Tomcat use the same output buffer, and the pages will load correctly. I tested tried that out, and it worked fine. I can't use it right now though, I have way too many HTML files, and links(internal and external) etc. 

The way I ended up solving this was to create a HttpServlet and filter all calls to *.html into it. Here's my code:

web.xml
<servlet>
<servlet-name>html</servlet-name>
<servlet-class>com.holstein.servlets.HTMLServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>html</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>


HTMLServlet.java

public class HTMLServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException, ServletException {
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
BufferedReader bw = new BufferedReader(new FileReader(req.getRequestURI().toString()));
while(bw.ready())
{
out.println(bw.readLine()); //this is an old school way to output the data.
// I think it's way out of form, and deprecated at this point
}
}
}


This is by no means a pretty fix, but it's functional. I need to do a major rewrite of our site and possibly get rid of Sitemesh for Tiles or something else. The other thing would be to get a pull on Sitemesh 3, and fix the the bug there (or wait for someone to do it). This assumes there isn't a version out there with the fix in it. 

I'm using Maven from mvnrepository.com to control all my dependencies. I have the latest Sitemesh from there, but I think it is a little stale. 



On Wednesday, November 5, 2014 at 8:44:52 PM UTC-5, Corrado Alesso wrote:
Reply all
Reply to author
Forward
0 new messages