tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: servlets and jsp with Tomcat 5.0
Date Tue, 27 Jul 2004 13:03:48 GMT

Hi,
I didn't see any question or error in your message.  What's wrong
(besides several sub-optimal coding practices) ?

Yoav Shapira
Millennium Research Informatics


>-----Original Message-----
>From: Bill Reynolds [mailto:BFR@DISC.com]
>Sent: Monday, July 26, 2004 7:22 PM
>To: tomcat-user@jakarta.apache.org
>Subject: servlets and jsp with Tomcat 5.0
>
>I am trying to get an older demo that was written 2-3 years ago (by
>someone else of course) working with Tomcat 5.0.
>
>   My current problem is when my service routine is called in the
>servlet for a new user, after doing the appropriate initialization of
>attaining a database connection from my connection pool, it calls
>returnToForm.
>
>   My context is called Household.
>
>   Here is the code snipet:
>
>    /*returnToForm(HttpServletResponse res, String page)
>     *Encodes and redirects the program to the specified page.
>     */
>    private void returnToForm(HttpServletResponse res, String page) {
>            try {
>                String sURL = res.encodeRedirectURL(page);
>                res.sendRedirect(sURL);
>            }catch(Exception e) {
>                writeToLog("returnToForm error: " + e);
>            }
>
>
>    /*service(HttpServletRequest req, HttpServletResponse res)
>     *This method is called for each client request. This method
>controls the flow
>     *of the program.
>     */
>    public void service(HttpServletRequest req, HttpServletResponse
res)
>throws IOException {
>        //Each client request has its own HttpSession object.
>        HttpSession session = req.getSession(true);
>
>        //The "command" parameter is an html <input> form object that
>informs the servlet
>        //what the client is requesting. Each "command" object has a
>"value" that is passed
>        //with the request.
>        String command = req.getParameter("command");
>
>        //If the "command" parameter value is null then this is a new
>client.
>        if(command==null){
>            newClient(req, res);
>            returnToForm(res,"/Household.jsp");
>
>        //If the "command" parameter value is "Query", then the client
>is
>        //requesting that the query be run using the selected criteria.
>        }else if(command.equals("Query")){
>            writeToLog("Getting counts");
>            boolean samelist = processForm(req);
>            samelist = false;
>            runQueries(req, samelist);
>            writeToLog("finished running queries. selecting
qualified");
>            writeToLog("Selecting qualified");
>            selectQualified(req);
>
>            returnToForm(res,"/Household.jsp");
>
>        //If the "command" parameter value is "Next", then the client
is
>
>        //requesting to view the next set of qualified records (next
>page). The records
>        //are displayed 10 rows at a time.
>        }else if(command.equals("Next")){
>            writeToLog("Getting next 10 rows");
>            getNext(req);
>            returnToForm(res,"/Household.jsp");
>
>        //If the "command" parameter value is "Previous", then the
>client is
>        //requesting to view the previous page.
>        }else if(command.equals("Previous")){
>            writeToLog("Getting previous 10 rows");
>            getPrevious(req);
>            returnToForm(res,"/Household.jsp");
>
>        //If the "command" parameter value is "Reset", then the client
>is
>        //requesting that everything be reset so they can begin again.
>        }else if(command.equals("Reset")){
>            writeToLog("Resetting form.");
>            clearAll(req);
>            returnToForm(res,"/Household.jsp");
>
>        //Any other value for the "command" parameter is invalid.
>        }else{
>            writeToLog("Something went wrong: " + command);
>        }
>    }
>
>
>   Thanks in advance for any help...
>   Bill Reynolds
>   bfr@disc.com
>



This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message