First JSP
I have a JSP - which accepts username and password for a website that does some online trading.
On clicking the submit button, I call a servlet that processes this request.
public class Login extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res)throws IOException, ServletException
{
String username, password;
boolean response = false;
// Gets username and password from the Login page.
userrname = req.getParameter("username");
password = req.getParameter("password");
//Using "ct" which was stored in ServletContext, validate the username and password.
CheckTable ct = (CheckTable)(getServletContext().getAttribute("ct"));
response = ct.validate(username,password);
//If user is found in the table, save his session and go to WelcomePage.jsp.
if (response == true)
{
session.setAttribute("username", username);
RequestDispatcher dp = getServletContext().getRequestDispatcher("/WelcomePage.jsp");
dp.forward(req,res);
}
// else return to LoginPage.jsp giving message- username not found in system or passowrd incorrect.
else
{
}
}
}
What are the changes I need to make for the above? How would I code the else part?

