You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2003/02/27 16:08:44 UTC

DO NOT REPLY [Bug 17490] New: - html:messages tag throws non speaking JSPException when key doesn't exist.

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17490>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17490

html:messages tag throws non speaking JSPException when key doesn't exist.

           Summary: html:messages tag throws non speaking JSPException when
                    key doesn't exist.
           Product: Struts
           Version: 1.1 Beta 3
          Platform: Sun
        OS/Version: Solaris
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Custom Tags
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: gehl_p@hotmail.com


the html:messages tag doesn't check the existence of a message for a key


Hi,

The struts-html:messages tag doesn't check if the message returned by the 
RequestUtils.message() method is not null.
So if the key is not attached to a message the pageContext.setAttribute() 
throws a NullPointerException (at least with Weblogic7.0)

see code in the org.apache.struts.taglib.html.MessagesTag class
1 : public int doStartTag()
[...]
2 : // Store the first value and evaluate, or skip the body if none
3 : if (iterator.hasNext()) {
4 :   ActionMessage report = (ActionMessage) iterator.next();
5 :   String msg = RequestUtils.message(pageContext, bundle, locale, 
report.getKey(),report.getValues());
6 :   pageContext.setAttribute(id, msg);

if the msg returned in line 5 is null the line 6 throws a NullPointerException
java.lang.NullPointerException
        at weblogic.utils.UnsyncHashtable.put(UnsyncHashtable.java:274)
        at weblogic.servlet.jsp.PageContextImpl.setAttribute
(PageContextImpl.java:128)
        at org.apache.struts.taglib.html.MessagesTag.doStartTag
(MessagesTag.java:203)
        at jsp_servlet._template.__ecct_45_template._jspService
(__ecct_45_template.java:228)
        at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
        at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:945)
        at weblogic.servlet.internal.ServletStubImpl.invokeServlet
(ServletStubImpl.java:332)
        at weblogic.servlet.internal.ServletStubImpl.invokeServlet
(ServletStubImpl.java:376)
        at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:20)
        at weblogic.servlet.internal.FilterChainImpl.doFilter
(FilterChainImpl.java:27)

A second problems appears, it's not the NullPointerException that comes out but 
a non speaking JSPException.

A possible solution could come from the struts-bean:message tag.
in the org.apache.struts.taglib.bean.MessageTag class there is the following 
code :

1 : public int doStartTag()
2 :   // Retrieve the message string we are looking for
3 :   String message = RequestUtils.message(pageContext, 
this.bundle,this.localeKey, key, args);
4 :   if (message == null) {
5 :     JspException e = new JspException(messages.getMessage
("message.message", key));
6 :     RequestUtils.saveException(pageContext, e);
7 :     throw e;
8 :   }

The code part from line 4 to 8 could be added after line 5 of the html:Messages 
code extract to avoid non speaking JSP Exception.


Regards

Pascal

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org