Arron Bates ([EMAIL PROTECTED]) wrote:

> Nice piece of work, it looks familiar...
> 
>   http://www.mail-archive.com/[EMAIL PROTECTED]/msg63442.html
> 
> ...never thought feedback on the solution would be like this, but each to
> their own. For those interested, the link contains code which can be used for
> any such filter operation.
Yep, I took your advice, I had just lost the reference to who had
originally suggested it.  I would have attached the code last time
but my stupid mail client is giving me an error and I have just too
flooded to play with configurations right now.  Here it is.

package net.creativerge.taglib.filter;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTagSupport;


public class Nl2brTag extends BodyTagSupport
{
    public int doStartTag() throws JspException
        {
                return EVAL_BODY_BUFFERED;
        }

        public int doAfterBody() throws JspException
        {
                BodyContent bodyContent = getBodyContent();

        if (bodyContent != null) {
            String body = bodyContent.getString();
            if (body != null)
                        {
                                body = body.replaceAll("\n", "<br />");
                                try
                                {
                                        bodyContent.getEnclosingWriter().println(body);
                                }
                                catch (Exception e)
                                {
                                        e.printStackTrace();
                                }
            }
        }

                return EVAL_PAGE;
        }
}


-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <[EMAIL PROTECTED]>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
It is not enough to succeed.  Others must fail.  
 -- Gore Vidal
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

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

Reply via email to