Kind of difficult without seeing the code for PreReadError, but it looks
like a servlet.context() issue.  Take a look at this in the API.

Mark

-----Original Message-----
From: Edward [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 17, 2002 10:00 PM
Importance: High


I have a question,it is very puzzle to me.I have a class named PreReadError,
it works well,it can read data from the file "error.data".For example:

...
 public static void main()
{
  String str;
  PreReadError test=new PreReadError();
  //notice here
  str=(String )test.getTable("Error0");
  System.out.println("Found Error0");
  System.out.println("It's value is "+str);
  ...
 }

It works well.When I run it,it will show:
  Found Error0
  It's value is 3

But when I use this class "PreReadError" in a servlet,for example:

...
public class GetUserIdentity extends HttpServlet
{
  public void doPost(HttpServletRequest request,HttpServletResponse
response)
     throws ServletException,IOException
 {
    PreReadError test=new PreReadError();
    PrintWriter out=response.getWriter();
    out.println("<html>");
    out.println("<body>");
    //notice here
    String str=(String )test.getTable("Error0");
    out.println("<p> It's value is "+str+"</p>");
    ....
 }

When I run GetUserIdentity,it should show:
  It's value is 3
But I got another result,it shows:
  It's value is null

I put my files in follows:
  I use Apache Tomcat4.0 again,I install Apache Tomcat4.0 into D:\Program
Files\Apache Tomcat4.0
I put my class GetUserIdentity.class and PreReadError.class into follows
folds:
  I put them into D:\Program Files\Apache
Tomcat4.0\Webapps\examples\WEB-INF\classes
then I also put the file error.txt into D:\Program Files\Apache
Tomcat4.0\Webapps\examples\WEB-INF\classes
when I run it ,I can't get proper result.If the error.txt location is false,
where it should be? I'm a newbie of JavaServlet,would you give me detailed
steps to correct it?
Please help me!
Thanks in advances!
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

___________________________________________________________________________
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