M
Miss Michelle. Heigardt
Hallo, I have two questions. I am new to Java programming in Servlets.
Question 1. I have a servlet that validates input from another servlet
"GetDetails" that generates a HTML page. If the stuff user entered is
correct I want to go to another page "ShowDetails". If the stuff the
user has entered is not correct I want to sent the page back to have
the information corrected. This is my code
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws ServletException{
RequestDispatcher dispatcher;
if (session.getAttribute("password")==null){
dispatcher=request.getRequestDispatcher("GetDetails");
}
else{dispatcher=request.getRequestDispatcher("ShowDetails");}
dispatcher.forward(req,res);
}
"ErrorPage" and "ShowDetails" are servlets that create out more HTML.
When this code executes it seems to works but the browser URL does not
change. Therefore I am not doing this right so what is the right way?
Question 2. Rather that putting "GetDetails" and "ShowDetails" in lots
of servlet class, is there a tool to put them in somewhere else and
have them looked up. By a tool I mean the way people do this, not what
I could write.
Thank you
Michelle
Question 1. I have a servlet that validates input from another servlet
"GetDetails" that generates a HTML page. If the stuff user entered is
correct I want to go to another page "ShowDetails". If the stuff the
user has entered is not correct I want to sent the page back to have
the information corrected. This is my code
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws ServletException{
RequestDispatcher dispatcher;
if (session.getAttribute("password")==null){
dispatcher=request.getRequestDispatcher("GetDetails");
}
else{dispatcher=request.getRequestDispatcher("ShowDetails");}
dispatcher.forward(req,res);
}
"ErrorPage" and "ShowDetails" are servlets that create out more HTML.
When this code executes it seems to works but the browser URL does not
change. Therefore I am not doing this right so what is the right way?
Question 2. Rather that putting "GetDetails" and "ShowDetails" in lots
of servlet class, is there a tool to put them in somewhere else and
have them looked up. By a tool I mean the way people do this, not what
I could write.
Thank you
Michelle