001// Copyright (c) 2001 Hursh Jain (http://www.mollypages.org) 
002// The Molly framework is freely distributable under the terms of an
003// MIT-style license. For details, see the molly pages web site at:
004// http://www.mollypages.org/. Use, modify, have fun !
005
006package fc.web.servlet;
007
008import java.io.*;
009import java.util.logging.*;
010import java.util.*;
011import javax.servlet.*;
012import javax.servlet.http.*;
013
014import fc.io.*;
015import fc.web.*;
016import fc.util.*;
017
018/** 
019Represents an action available to a servlet. 
020
021@author hursh jain
022**/
023public abstract class Action
024{
025protected final String    name;
026
027/**
028Constructs a new Action and registers it with the specified
029{@link ActionMgr}
030
031@param  name  the name of this action. Action names should be 
032        unique within a given {@link ActionMgr}. This is
033        the value of the <tt>act</tt> parameter submitted 
034        by the web client and is used to dispatch to this
035        action.
036
037**/
038protected Action(String name) 
039  {
040  Argcheck.notnull(name, "name param was null");
041  this.name = name;
042  }
043
044/** 
045Subclasses should implement this method to carry out a particular
046action
047**/
048abstract 
049public void handle(HttpServletRequest request, HttpServletResponse res) 
050throws Exception; 
051  
052/**  
053Returns the name of this action.
054**/
055public String getName() {
056  return name;
057  }
058
059public String toString() {
060  return getClass().getName() + "; action=" + name;
061  }
062
063}          //~class Action