I am trying to read in a file using a java servlet.  If I place the absolute
path name in... The servlet works great.  But, If I place the reletative
address in it does work.  Here is my code:

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class guestbook extends HttpServlet
{
        public void doGet(HttpServletRequest req, HttpServletResponse res)
                throws ServletException, IOException
                {
                        res.setContentType("text/html");
                        //ServletOutputStream fos = res.getOutputStream();

                        String InputFile = "d.txt";

                        PrintWriter out = res.getWriter();

                  try
                        {
                                String fileLine;

                                // Get the  file specified by InputFile
                                BufferedReader br = new BufferedReader(new 
InputStreamReader(new
FileInputStream(InputFile)));

                                //while there are still lines in the file, get-em.
                                while((fileLine = br.readLine())!= null)
                                {
                                        out.println(fileLine);
                                        //add each line to the vector, each line will 
have a CRLF
                                        //v.addElement(fileLine);
                                }

                                br.close();
                        }
                        catch(IOException e)
                        {
                                out.println("An error occurred reading the file " + e);
                        }


                        out.println("<html>");
                        out.println("<head><title>Guest Book</title></head>");
                        out.println("<body>");
                        out.println("Name: ");
                        out.println("</body></html>");
                        out.close();
           }




}

The code above produces an error.  Could some one please tell me what I am
doing wrong?????

Thanks
-Larry H.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to