PageEncodingTag.java :  » Wiki-Engine » VeryQuickWiki » vqwiki » tags » Java Open Source

Java Open Source » Wiki Engine » VeryQuickWiki 
VeryQuickWiki » vqwiki » tags » PageEncodingTag.java
package vqwiki.tags;

import vqwiki.Environment;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import java.io.UnsupportedEncodingException;

import org.apache.log4j.Logger;

/**
 * By Colin Jacobs, coljac@coljac.net
 * Date: Aug 23, 2005
 * (c) 2005
 */
public class PageEncodingTag extends TagSupport {

    private static final Logger logger = Logger.getLogger(CurrentUserTag.class);

    /**
     *
     */
    public int doEndTag() throws JspException {
        String enc = Environment.getInstance().getForceEncoding();
        if (enc != null) {
            try {
                pageContext.getRequest().setCharacterEncoding(enc);
                pageContext.getResponse().setContentType("text/html;charset=" + enc);
            } catch (UnsupportedEncodingException e) {
                logger.warn("Unsupported encoding: " + enc);
                // Do nothing
            }
        }
        return EVAL_PAGE;
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.