This is my index.jsp page
HTML Code:
<body> <h1>Login: </h1> <form name="myForm" action="getPassword" method="POST"> Name <input type="text" name="uName" value="" /><br /> Password: <input type="password" name="uPass" value="" /><br /> Address <input type="text" name="uAddress" value="" /><br /> Phone <input type="text" name="uPhone" value="" /><br /> Email <input type="text" name="uEmail" value="" /><br /> <input type="submit" name="btSubmit" value="Send" /> </form> </body>
Code:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String uPhone = request.getParameter("uPhone");
String uEmail= request.getParameter("uEmail");
if(uPhone ?????????){
RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher("/Correct.jsp");
dispatcher.forward(request, response);
return;
}else{
RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher("/Wrong.jsp");
dispatcher.forward(request, response);
return;
}
I want to A Servlet that:
- checks the phone number has only numbers and no characters
- checks if the email address has '@' (at) symbol and a '.' (dot) in it
What should I wrote in ???? place
