FileDocCategorySizeDatePackage
RootRequestHandler.javaAPI DocApache log4j 1.2.154066Sat Aug 25 00:09:34 BST 2007com.psibt.framework.net

RootRequestHandler

public class RootRequestHandler extends Object implements HTTPRequestHandler
This class implements a RequestHandler for the root path "/" in the PluggableHTTPServer. A simple HTML message will be replied to the client.
author
Volker Mentzner

Fields Summary
private String
title
private String
description
private String
handledPath
private String
ReplyType
private String
ReplyHTML
Constructors Summary
public RootRequestHandler()
Creates a new RootRequestHandler object


         
    
    this.setTitle("root page");
    this.setDescription("root page");
    this.setHandledPath("/");
  
Methods Summary
public java.lang.StringgetDescription()
Gets the description for html page

    return this.description;
  
public java.lang.StringgetHandledPath()
Gets the server path

return
the server path

    return this.handledPath;
  
public java.lang.StringgetReplyHTML()
Gets the HTML data of the reply HTTP message

return
HTML message as String

    return this.ReplyHTML;
  
public java.lang.StringgetReplyType()
Gets the content type of the reply HTTP message

return
content type as String

    return this.ReplyType;
  
public java.lang.StringgetTitle()
Gets the title for html page

    return this.title;
  
public booleanhandleRequest(java.lang.String request, java.io.Writer out)
Handles the given request and writes the reply to the given out-stream.

param
request - client browser request
param
out - Out stream for sending data to client browser
return
if the request was handled by this handler : true, else : false

    String path = "";
    String query = null;
    try {
      URL url = new URL("http://localhost"+request);
      path = url.getPath();
      query = url.getPath();
      if (path.equals(handledPath) == false) {
        return false;
      }

      out.write("HTTP/1.0 200 OK\r\n");
      if (ReplyType != null)
        out.write(ReplyType);
      if (ReplyHTML != null)
        out.write(ReplyHTML);
      out.flush();
      return true;
    } catch (Exception ex) {
      return false;
    }
  
public voidsetDescription(java.lang.String description)
Sets the description for html page

    this.description = description;
  
public voidsetHandledPath(java.lang.String path)
Sets the server path

param
path - the server path

    this.handledPath = path;
  
public voidsetReplyHTML(java.lang.String ReplyHTML)
Sets the HTML data of the reply HTTP message

param
ReplyHTML - HTML message as String

    this.ReplyHTML = ReplyHTML;
  
public voidsetReplyType(java.lang.String ReplyType)
Sets the content type of the reply HTTP message

param
ReplyType - content type as String

    this.ReplyType = ReplyType;
  
public voidsetTitle(java.lang.String title)
Sets the title for html page

    this.title = title;