I have a Hash table,I want to place it into context of a servlet,so this Hash table 
can be called by any users.My Hash table file named "PreReadError.java",it is follows:
 public class PreReadError
{
   public PreReadError()
  {
     Hashtable table=new Hashtable();
      table.put("Error0","Error");
      table.put("Error1","Redirect");
  }

  public String getTable(String str)
 {
  String result=(String) table.get(str);
  return result;
 }
}


My servlet file named "GetUserIdentity.java" is follows:

import javax.servlet.ServletContext;
public class GetUserIdentity extends HttpServlet
{
  PreReadError readfile;
  String errorfile;
  String str;
  ServletContext context;

  public GetUserIdentity()
 {
    context=getServletContext();
 }

 public void doPost(HttpServletRequest request,HttpServletResponse response)
     throws ServletException,IOException
 {
    //Here,I want to create a context if it is not exist,else call it's method directly
    if(context.getAttribute("errorfile")==null)
    {
       readfile=new PreReadError();
       context.setAttribute(errorfile,readfile);
    }
    str=(String )errorfile.getTable("Error0");
    System.out.println("Message is:"+str);
  }
 }
}

When I compile it,it raise a error,it follows:

F:\login\ejb>javac -classpath .;f:\j2sdkee1.3.1\lib\j2ee.jar GetUserIdentity.java

GetUserIdentity.java:55: cannot resolve symbol
symbol  : method getTable  (java.lang.String)
location: class java.lang.String
                        str=(String )errorfile.getTable("Error0");
                                              ^
1 error

I don't know how to put my Hashtable into a servlet and how to call it's methods?
Any idea will be appreciated!
Thanks in advance.
Edward

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to