I got the July issue of JDJ today. In it I found a good article on JSP 2.0 (printable, less ads version). Things I learned from the article:
- JSTL 1.1 will introduce 16 standardized EL functions:
- fn:length(): Get the length of a collection or a string.
- fn:toUpperCase(), fn:toLowerCase(): Change the capitalization of a string.
- fn:substring(), fn:substringBefore(), fn:substringAfter(): Get a subset of
a string.
- fn:trim(): Trim whitespace from a string.
- fn:replace(): Replace characters in a string.
- fn:indexOf(), fn:startsWith(), fn:endsWith(), fn:contains(), fn:containsIgnoreCase():
Check if a string contains another string.
- fn:split(): Split a string into an array.
- fn:join(): Join a collection into a string.
- fn:escapeXml(): Escape XML characters in a string.
- The tag libraries in JSTL 1.1 have new URIs (for example, http://java.sun.com/jsp/jstl/core instead of the JSTL 1.0 equivalent http://java.sun.com/jstl/core_rt). The new JSTL 1.1 tag libraries accept request-time expressions for their attributes, and delegate to the JSP container to evaluate EL expressions.
Good stuff to know. I'm ready to start developing JSP 2.0 apps - I hope the Tomcat dev team releases a stable build soon. Or maybe I should just look into using Resin...
I'm having some issues with implementing a Compression Filter in my day-time project. It works fine via the browser (and in AppFuse/Roller), but not in one of my Webtests. I think this is because my response doesn't have anything in it, but who knows. From my log file:
CompressionFilter.doFilter(87) | Unzipped size: 0
CompressionFilter.doFilter(106) | Zipped size: 20
And then the lovely error message from my testcase:
[canoo] java.io.EOFException
[canoo] at java.util.zip.GZIPInputStream.readUByte(GZIPInputStream.java:200)
[canoo] at java.util.zip.GZIPInputStream.readUShort(GZIPInputStream.java:190)
[canoo] at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:130)
[canoo] at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:58)
[canoo] at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:68)
[canoo] at com.meterware.httpunit.WebResponse.defineRawInputStream(WebResponse.java:617)
I'm thinking I need to close a stream or something, but since it works fine via the browser - I'm stumped! Any ideas are appreciated. I can post the testcase if necessary.
Update: Richard Hill on the Webtest mailing list hooked me up with the solution. It turned out to be a bug in the JDK, which causes issues in HttpUnit. Here's the solution I used to workaround it.
I converted AppFuse to use JSTL's <fmt:message> tag instead of Struts' <bean:message> tags this morning. It was pretty easy. Here's the steps I took:
1. First, I added the following to metadata/web/seb-settings.xml:
<!-- Define the basename for a resource bundle for I18N -->
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>ApplicationResources</param-value>
</context-param>
2. Then I added the format tag to web/common/taglibs.jsp:
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
3. Finally, I did find/replace with <bean:message/<fmt:message.
4. I also had to change my title and header keys in
web/WEB-INF/tiles-config.xml to remove the . from the bean names. In
other words, I converted title.key and heading.key to titleKey and headingKey and also made the appropriate changes in web/layouts/baseLayout.jsp.
Easy as Pie!