Showing posts with label jsp. Show all posts
Showing posts with label jsp. Show all posts

Friday, September 06, 2013

JSP/JSTL migration problem

While migrating some of my work stuff from my old WinXP laptop (ThinkPad T500... good old machine) to my new Windows 7 T430 (also fine iron), I switched from Tomcat v5 (yes, indeed, old) to Tomcat v7.
Tomcat v7 comes with a new servlet, JSP and EL spec. Not a real problem - I thought.

But once I got all the data sources etc up and running, my JSPs would not compile and gave EL parsing errors like "javax.el.ELException: Failed to parse the expression".

A bit googling revealed this nice post on Stackoverflow.

Turns out, that with the new EL standard, Java keywords are forbidden as variables.

And I had "static" as an URL parameter  in ${empty param.static} as well as "class" as a variable to hold css/style class-names.

Once I renamed those everything worked fine again.
The first once was nasty, though, because as an URL parameter the name was of course exposed externally... Had to change some other scripts as well.

Saturday, January 26, 2008

JSTL fineprint

The following fine print in the JSTL fmt:formatDate documentation just cost me about 45 minutes of my life:
If this action fails to determine a formatting locale, it uses java.util.Date.toString() as the output format.
Meaning that, if you do not set the locale explicitly in the JSP (with fmt:setLocale) and you e.g. use WGET against your JSP page - which per default does not carry any locale information - you get the stupid default format
Sat Jan 26 18:10:50 CET 2008
instead of whatever you specify. Even if you explicitly give a pattern with fmt:formatDate value="${now}" pattern="yyyy-MM-dd'T'HH:mm:ss'Z'"
you nevertheless get the verbose stuff from above.
You have to setLocale first...

Sick. Just sick.

Monday, March 12, 2007

displaytag library fix details

I noticed some interest in my post about the fix in the displaytag libarary and have recently also been asked to post the fix:
here's what I did to the org.displaytag.decorator.TotalTableDecorator.java file:

public final String finishRow()
{
StringBuffer buffer = new StringBuffer(1000);

// Grand totals...
Object decoratedObject = getDecoratedObject();
int decObjSize=0;

if (decoratedObject instanceof Collection)
{
decObjSize = ((Collection)decoratedObject).size();
}
else
{
if (decoratedObject instanceof SortedMap[] )
{
decObjSize = ((Object[])decoratedObject).length;
}
}

if (getViewIndex() == (decObjSize - 1))
{
if (groupPropertyName != null)
{
buffer.append(createTotalRow(false));
}
buffer.append(createTotalRow(true));
}
return buffer.toString();
}

the main thing is that I also accept Arrays and not only Lists (as in the original code)