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
[EMAIL PROTECTED]