Bad JSP, Naughty JSP
Comments:

Just thought you might be interested. In PHP, you can just turn on output buffering and capture the output of any bit of code.

Posted by Keith on January 19, 2003 at 06:56 PM CST
Website: http://www.keithdevens.com/ #

Okay so basically I want:

String jspContent;

long timeout = System.currentTimeMillis();
.....
if (jspContent == null || System.currentTimeMillis() - timeout > (60 * 100 * 30)) {
jspContent = JSP(pagename, request, response);

myCache.put("jsp",jspContent);
}

And store the content. Go look at http://jakarta.apache.org/jetpseed. My portlet is a JspPortlet... So unlike the other portlets, the content is written using an include and then an empty ECS String component is returned.

I want to cache this. (well this is going to look like crap because I can't use <p> but you get the idea)

Posted by Andy on January 19, 2003 at 10:04 PM CST
Website: http://cvs.apache.org/~acoliver #

Okay, now I understand. I've never encountered this usecase, but have always used Filters to cache JSP output. Includes should result in the included page's content in the BodyContent, which you can ask getString() of, and which end up in the Response.outputStream.



Looking briefly through the Jetspeed/Turbine code, it looks like JspPortlet will always return a blank ElementContainer. The DefaultRunDataWhatever can be asked for getOut() though, so perhaps JspPortlet should be asking the RunData for out, and using the Stream to get the actual content generated. This is all based on a 15 minute walk through the code, so my statement is more than likely invalid.

Posted by Lance on January 20, 2003 at 09:02 AM CST #

Nope... for starts...filters weren't in Tomcat 3.2.3 which we're stuck on. (so how you always used them is beyond me ;-) ). The run data has no access to the JSP, the JSP is being included in the request output stream. About the only thing that might work (other than what I did) is to construct a faux HttpResponse which contains a fake output stream that I have access to and intercept it.. . But boy that would be messy.

Posted by Andy on January 21, 2003 at 09:22 AM CST
Website: http://cvs.apache.org #

Always for the last 1.25 years, that's how. Frankly the stuff I've worked on has either been low latency or low traffic, so we didn't need caching (no premature optimization here). Like I said, I just perused the codebase so I don't really grok the architecture, but it *looks* like RunData should have access to what you need but that JspPortlet isn't taking advantage of it.

Posted by Lance on January 21, 2003 at 09:57 AM CST #

Comments have been disabled.