You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Maya Muchnik <mm...@pumatech.com> on 2000/12/29 20:51:58 UTC

a problem with response taglibs

Hi,

If anyone knows why senderror.jsp using SendErrorTag.java does not work?
In the Netscape browser and Tomcat 3.1 as the Web server it first
displays a "User and Password Required" window with two data fields
"User Name" and "Password". After entering some name and password and
/or canceling, text of senderror.jsp returns to the browser without this
ending part:

<%@ taglib uri="response.tld" prefix="res" %>
<res:senderror error="SC_UNAUTHORIZED" reset="true">
Test of RESPONSE tag library senderror!
</res:senderror>
</body>
</html>

Here is full text of senderror.jsp:

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
   <meta name="GENERATOR" content="Mozilla/4.74 [en] (X11; U; FreeBSD
3.4-RELEASE i386) [Netscape]">
   <title>Jakarta RESPONSE Taglib Example</title>
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B"
alink="#FF0000">

<%@ taglib uri="response.tld" prefix="res" %>
<res:senderror error="SC_UNAUTHORIZED" reset="true">
Test of RESPONSE tag library senderror!
</res:senderror>
</body>
</html>

Thanks,

Maya

Re: a problem with response taglibs

Posted by Glenn Nielsen <gl...@voyager.apg.more.net>.
Maya,

You didn't find a bug.  The error message you include in the tag body
is  not for display in the current page, it is the error message sent
back to the users browser along with the HTTP error code.  Look at the
JavaDoc for HttpServletRespons.sendError( int err, String msg);

Regards,

Glenn

Maya Muchnik wrote:
> 
> Hi, all,
> I am sorry to butter you again. In the response tag library, senderror tag has
> "restrictions" about using the tag body for an error message. It does not work
> - the error message is "non visible". When I have changed the
> SendErrorTag.java as the following (changes are in red color):
> 
> public class SendErrorTag extends BodyTagSupport
> {
>     private int error = 0;
>     private boolean reset = false;
>     private String errMsg;   // added
> ...
> }
> public final int doAfterBody() throws JspException
> {
>         // Use the body of the tag as header value
>         BodyContent body = getBodyContent();
>         String s = body.getString();
>         errMsg = s;   // added
> ...
> }
> public final int doEndTag() throws JspException
> {
>         // added the following text
>         try {
>             pageContext.getOut().write(errMsg);
>         } catch(Exception e) {
>             throw new JspException("IO Error: " + e.getMessage());
>         }
>         return EVAL_PAGE;
>         //return SKIP_PAGE;
> }
> ...
> After that, the error message between start and end tag became "visible". Is
> this a bug, or I am not correct?
> P.S. See senderror.jsp also.
> 

-- 
----------------------------------------------------------------------
Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------

Re: a problem with response taglibs

Posted by Maya Muchnik <mm...@pumatech.com>.
Hi, all,
I am sorry to butter you again. In the response tag library, senderror
tag has "restrictions" about using the tag body for an error message. It
does not work - the error message is "non visible". When I have changed
the SendErrorTag.java as the following (changes are in red color):

public class SendErrorTag extends BodyTagSupport
{
    private int error = 0;
    private boolean reset = false;
    private String errMsg;   // added
...
}
public final int doAfterBody() throws JspException
{
        // Use the body of the tag as header value
        BodyContent body = getBodyContent();
        String s = body.getString();
        errMsg = s;   // added
...
}
public final int doEndTag() throws JspException
{
        // added the following text
        try {
            pageContext.getOut().write(errMsg);
        } catch(Exception e) {
            throw new JspException("IO Error: " + e.getMessage());
        }
        return EVAL_PAGE;
        //return SKIP_PAGE;
}
...
After that, the error message between start and end tag became
"visible". Is this a bug, or I am not correct?
P.S. See senderror.jsp also.


Re: a problem with response taglibs

Posted by Maya Muchnik <mm...@pumatech.com>.
I have read documentation and I understand what happens. Sorry for any
interruption.