Hi all...
I am a beginner to servlets. I am trying to send an html file to the user by reading 
the file and then out.println (filename). But every time I run the servlet, Filenot 
found exception occurs. I am not able to figure out the problem. The html file is in 
the same directory as the java code.
details:
directory structure
c:\yogesh\codes\HTMLServlet.java
c:\yogesh\codes\rayarsrl.html
c:\jsdk2.0\examples\HTMLServlet.class
c:\jsdk2.0\examples\rayararl.html

code : HTMLServlet.java
—--------------------------------------------------------------------------------------------
import javax.servlet.*;
import java.io.*;
import javax.servlet.http.*;

public class HTMLServlet extends HttpServlet {

    public void doGet(HttpServletRequest request,HttpServletResponse response)
    {
           try {

                File inputFile;

                PrintWriter out;
                response.setContentType("text/html");
                out = response.getWriter();
                out.println("Step1");

                inputFile = new File("rayarsrl.html");
                out.println("Step2");

                BufferedReader reader =
                 new BufferedReader( new FileReader(inputFile));
                out.println("Step3");
                int c;
                while((c=reader.read()) != -1)
                {
                     out.println("Step4");
                     out.println(c);
                }

                reader.close();
                out.close();
               } catch(FileNotFoundException e)
                {
                  System.out.println("Error....File not found");
                } catch(IOException e1)
                {
                  System.out.println("Error....IO Exception");
                }


            }
}
Every time the program compiles with no errors but when I run the servlet, the page is 
not displayed and filenotfound exception occurs.
Any instant help on this matter will be highly appreciated.
Thanx
Yogesh

___________________________________________________________________________
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