I have a html signup.html page containing name, id ,password and confirm password paremeters, and in the
servlet called SignUp.java i a condion that if either name or id are empty, then on clicking the submitt button it should print "One of the mandatary field is empty in the same page(in red color), but it is not doing that. please help me, thanks
here are the codes:
//signup.html
<html>
<body>
<h1 align = "center">New User Account</h1>
<form method = "GET" action = "SignUp">
<P>
Enter Your Name<span class="style1">*</span> :  
<Input Type = "text: name = "name"><br>
Enter User Name<span class="style1">*</span> :  
<Input Type = "text: name = "id"> @amanmail.com <br>
Enter Password<span class="style1">*</span> :    
<Input Type = "text: Password = "pwd"> <br>
Confirm Password<span class="style1">*</span>:  
<Input Type = "text: Password = "pwd1"> <br></P>
<P>
<input type = "SUBMIT" value = "Enter"> <br>
<a href = "Main.html">Return</a></P>
</form>
</body>
</html>
/////////////////////////////////////////
//SignUp.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SignUp extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res)throws IOException, ServletException
{
res.setContentType("html/text");
PrintWriter pw = res.getWriter();
String name = req.getParameter("name");
String id = req.getParameter("id");
String pwd = req.getParameter("pwd");
String pwd1 = req.getParameter("pwd1");
if( (name == null) || (id == null) )
{
pw.println("One of the Mandatary field is empty");
}
else
{
pw.println("Congratulations" + name +" yow have successfully signup");
pw.println("Your login id is" +id);
}
}
public void doPost(HttpServletRequest req, HttpServletResponse res)throws IOException, ServletException
{
doGet(req,res);
}
}
///////////////////////////////////
//web.xml
<web-app>
<servlet>
<servlet-name> signup </servlet-name>
<servlet-class> SignUp </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> signup </servlet-name>
<url-pattern> /SignUp </url-pattern>
</servlet-mapping>
</web-app>