Hi there

[Running Tomcat 5.0.19]

I have a servlet which forwards a Boolean object resource (request.setAttribute("someBoolean", someBoolean);) on to a jsp page. As you know there is no default constructor for this object (new Boolean()). In previous versions of Tomcat, well 5.0.16 and less, this didnt become a problem, as long as the Boolean was not null. In 5.0.19 the jsp compile throws an error because it includes code to make a new object were it null.

The generated servlet code that throws the error is:

java.lang.Boolean someBoolean = null;

synchronized (request) {

someBoolean = (java.lang.Boolean) _jspx_page_context.getAttribute("someBoolean", PageContext.REQUEST_SCOPE);

if (someBoolean == null){

someBoolean = new java.lang.Boolean();

_jspx_page_context.setAttribute("someBoolean", canEdit, PageContext.REQUEST_SCOPE);

}

Of course, the compiler doesnt like new java.lang.Boolean();

This seems to have just become a problem in this version of Tomcat. Can anyone shed any light on this?

5.0.16 handled this situation with the following snippet for the same scenario:

java.lang.Boolean someBoolean = null;
synchronized (request) {
canEdit = (java.lang.Boolean) pageContext.getAttribute("someBoolean", PageContext.REQUEST_SCOPE);
if (canEdit == null){
try {
someBoolean = (java.lang.Boolean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "java.lang.Boolean");
} catch (ClassNotFoundException exc) {
throw new InstantiationException(exc.getMessage());
} catch (Exception exc) {
throw new ServletException("Cannot create bean of class " + "java.lang.Boolean", exc);
}
pageContext.setAttribute("someBoolean", someBoolean, PageContext.REQUEST_SCOPE);
}


Sorry about the messy generated code. I could of course do this other ways (wrap Boolean into MyBoolean, and handle the situation with a default constructor, but would prefer not to. Any help/advice appreciated.

Thanks

Rup

--
Rupert Jones
--------------
http://www.rupertjones.com/


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to