HTTPException.java :  » Web-Server » tornado » tornado » Java Open Source

Java Open Source » Web Server » tornado 
tornado » tornado » HTTPException.java
// $Id: HTTPException.java,v 1.5 2001/01/11 05:16:27 nconway Exp $
package tornado;

public class HTTPException extends Exception {
    private final int statusCode;

    /** Constructs a new exception with the specified error code.
      * Numeric error codes are specified by the HTTP standard.
      */
    HTTPException(int statusCode) {
        this.statusCode = statusCode;
    }

    /** Returns the error code of this exception.*/
    public int getCode() {
        return statusCode;
    }

    /** Returns the HTML error page that should be shown to the
      * HTTP client.
      */
    public String getErrorPage() {
        StringBuffer page = new StringBuffer(120);
        page.append("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\"");
        page.append("<HTML><BODY><H1 ALIGN=CENTER>Error ");
        page.append(statusCode);
        page.append("</H1></BODY></HTML>");
        return page.toString();
    }

}
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.