Hi,
I'm not sure but I think that you to insert the complete path of the
file something like:
input=new BufferedReader(new FileReader("D:\\Apache Tomcat
4.0\\webapps\\login\\WEB-INF\\classes\\error.txt"));Regards Rinaldo -----Messaggio originale----- Da: A mailing list for discussion about Sun Microsystem's Java Servlet API Technology. [mailto:[EMAIL PROTECTED]] Per conto di Sanjeev Verma Inviato: venerd� 24 maggio 2002 10.59 A: [EMAIL PROTECTED] Oggetto: Re: Why I can't open my file? Just an idea...modify your code to first create the file...like this: output=new BufferedWriter(new FileWriter("my.txt")); Then, execute the servlet containing this code. You will know what is the path where you need to place your error.txt... Regards Sanjeev -----Original Message----- From: Edward [mailto:[EMAIL PROTECTED]] Sent: Friday, May 24, 2002 11:27 AM To: [EMAIL PROTECTED] Subject: Why I can't open my file? Importance: High I have a question about open file at same directory.I have some files,like follows: D:\Apache Tomcat 4.0\webapps\login\WEB-INF\classes\GetUserIdentity.class D:\Apache Tomcat 4.0\webapps\login\WEB-INF\classes\error.txt The role of GetUserIdentity.class is read data from the file "error.txt",The file "GetUserIdentity.java" like: ... try { input=new BufferedReader(new FileReader("error.txt")); ... } catch(IOException e) { e.printStackTrace(); } But when I start Apache Tomcat 4.0,and I visit index.html which locate http://localhost:8080/login/servlets/index.html index.html is follows: <html> <head> <title>Check Identity</title> <STYLE>.red {background-color:red;}</STYLE> </head> <body> <center> <br><br> <form action="http://localhost:8080/login/servlet/GetUserIdentity" method="POST"> <table align="center" width="%100" cellspacing="2" cellpadding="2"> <tr> <td align="right">Input ID </td> <td><input type="Text" name="ID" align="left" size=15></td> </tr> <br><br><br> <tr> <td align="right">Input Password </td> <td><input type="password" name="password" align="left" size=15 color="red"></td> </tr> </table> <br><br> <input type="Submit" name="okbutton" value=" OK " > <input type="button" name="cancelbutton" value=" Cancel " onclick="window.close()"> </form> </center> </body> <html> Then I click OK button,I got errors: Starting service Tomcat-Standalone Apache Tomcat/4.0.1 Starting service Tomcat-Apache Apache Tomcat/4.0.1 java.io.FileNotFoundException: error.txt at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(Unknown Source) at java.io.FileReader.<init>(Unknown Source) at PreReadError.<init>(PreReadError.java:22) at GetUserIdentity.<init>(GetUserIdentity.java:20) at java.lang.Class.newInstance0(Native Method) at java.lang.Class.newInstance(Unknown Source) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:82 0) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.jav a:615) at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServl et.java:396) at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.jav a:216) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:243) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline .java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:201) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline .java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java: 2344) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:164) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline .java:566) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche rValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline .java:564) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline .java:564) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java: 462) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline .java:564) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:163) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline .java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcesso r.java:1011) at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.ja va:1106) at java.lang.Thread.run(Unknown Source) I have put GetUserIdentity.class and error.txt in same dictionary,but why can't find it? Any idea will be appreciated! 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 ___________________________________________________________________________ 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
