Hi.  New to Servlets....

I have written a simple java CGI that sorts about 260 rows of a table as read in
from a tab-delimited text file generated by Excel.
The CGI works fine.  I have since then attempted to convert it into a Servlet
but with little luck.  My servlet references classes created for my CGI that
reads from the text file and creates an HTMLTable object from the
HTMLTable("filename") constructor I created.   The printHTML() method then
returns a string containing the necessary code for the proper browser display.
Again, everything works fine in the CGI implementation.  But when I create my
Servlet and test it using the servletrunner utility, all I get is blank output
in my browser window!  My servlet also reads from another file to collect a
header and footer for the page i wish to display.  Then once it reads the <TABLE
border> tag in the file, it replaces the table with the servlet generated sorted
table.

I realize that a JDBC- Servlet-SSI solution may be better but I do not have an
RDBMS at my disposal and am presently familiarizing myself with SSI's.  I will
be moving to in the near future however to DB2.   So once I learn the JDBC API
and SSI's,  I will also need to read from the DB2 table and sort the results.
Here is a sample of my (very simplistic) source code...

Is it a servlet configuration error that I have commited? I simply altered the
servlet.properties file to reflect the addition of my new servlet.  The
following lines where added to the servlet.properties file...

# toolbox servlet
servlet.session.code = ToolboxServlet


Here is a sample of my (very simplistic) source code...


public class ToolboxServlet extends HttpServlet{

        public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException{

                PrintWriter out;

                response.setContentType("text/html");

                out = response.getWriter();

                HTMLTable me = new HTMLTable("tab_delimited_table_content.txt");
                me.loadTable("tab_delimited_table_content.txt");
                String HTMLCode = printBody("header_footer.html", me);

                out.println(HTMLCode);
                out.close();
       }

       public String printBody(String filename, HTMLTable table){
        TextInputStream inFile = new TextInputStream(filename);
        String s=inFile.readLine();
        boolean withinTable = false;
        String me = "<!-- HTML Code generated by ToolbBoxServlet --> ";

        while (! inFile.fail()){
                s=inFile.readLine();
                if (0 <= s.indexOf("<Table border>") && ! withinTable){
                        me = me.concat(table.printTable());
                        withinTable = true;
                }
                if (0 <= s.indexOf("</Table>") && withinTable) withinTable =
false;
                if (! withinTable) me = me.concat(s + "\n");
        }

        return me;
       }
}


Thanks for you time.


A.

___________________________________________________________________________
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