I wrote this very simple servlet to take one argument from the URL ( page ) and
display the corresponding page.  However, I am having trouble with the flow
control logic.  page== "init" always evaluates to false.  Can someone explain to
me what I am doing incorrectly.
Setup is Windows NT Workstation (SP3), Apache, Apache JServ, JDK1.3, JSDK2.0

The source follows:


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


public class SimpleApp extends HttpServlet {

    public void displayPage ( PrintWriter out , String filename ) {
        String page;
        try {
            RandomAccessFile inFile = new RandomAccessFile(
"D\\web\\htdocs\\simpleApp\\" + filename,"r");
                while( (page = inFile.readLine()) != null ) {
                        out.print(page);
                }
                inFile.close();
        }
        catch(FileNotFoundException exception) {
                out.println("File " + filename + " not found!");
        }
        catch(IOException exception) {
                out.println("Error opening file " + filename + " for reading!");
        }
    }
    public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
        // get an PrintWriter from the response object
        PrintWriter out = response.getWriter();
        // prepare the response's content type
        response.setContentType("text/html");
        // get the page to display
        String page = request.getParameter("page");


        // print to the output stream!
        if( (page == "init" )  || (page == "Start Over" ) ) {
                displayPage( out , "index.html" );
        }
        if( page ==  "Confirm" ) {
                displayPage( out, "confirm.html") ;
        }
        if( page == "Done" ) {
                displayPage( out, "done.html" );
        }
    }
}

Kh�rt Williams
President
Williams Inter@ctive, Inc.
+1 (732) 422-1570
+1 (732) 241-8667 (Cellular)
http://www.williamsinteractive.com
[EMAIL PROTECTED]
___________________________________________________________________________
Visit http://www.visto.com/info, your free web-based communications center.
Visto.com. Life on the Dot.

___________________________________________________________________________
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