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
006 package fc.web.servlet;
007
008 import java.io.*;
009 import java.util.logging.*;
010 import java.util.*;
011 import javax.servlet.*;
012 import javax.servlet.http.*;
013
014 import fc.io.*;
015 import fc.web.*;
016 import fc.util.*;
017
018 /**
019 Represents an action available to a servlet.
020
021 @author hursh jain
022 **/
023 public abstract class Action
024 {
025 protected final String name;
026
027 /**
028 Constructs 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 **/
038 protected Action(String name)
039 {
040 Argcheck.notnull(name, "name param was null");
041 this.name = name;
042 }
043
044 /**
045 Subclasses should implement this method to carry out a particular
046 action
047 **/
048 abstract
049 public void handle(HttpServletRequest request, HttpServletResponse res)
050 throws Exception;
051
052 /**
053 Returns the name of this action.
054 **/
055 public String getName() {
056 return name;
057 }
058
059 public String toString() {
060 return getClass().getName() + "; action=" + name;
061 }
062
063 } //~class Action