im trying to validate a user sign up form.
The jsp page submits the values to a vailidateRegister servlet which then if the form fields contain relevent data it directs it on to another servlet which then stores the details in a database. However, even with relevent data in fields it redirects me back to the register.jsp (form) page and does not submit data to the insert servlet
hope this is enough description
any ideas
heres the code for the validation servlet (where i think the problem is)
import java.io.*;
import java.sql.*;
import java.lang.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class validateRegister extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
String strName = req.getParameter("Name"
String strEmail = req.getParameter("Email"
String strPhone = req.getParameter("Phone"
String strPassword = req.getParameter("Password"
String strPassword2 = req.getParameter("Password2"
String strPostCode = req.getParameter("PostCode"
String strError = "";
PrintWriter out = res.getWriter();
out.println("<html>"
out.println("<boby>"
if ((strName == null) || (strName.length() == 0)){
strError +=" !You must enter a valid Name ! ";}
if ((strEmail == null) || (strEmail.length() == 0)){
strError +=" !You must enter a valid Email ! ";}
if ((strPhone == null) || (strPhone.length() == 0)){
strError +=" !You must enter a valid Phone Number ! ";}
if((strPassword == null) || (strPassword.length() == 0)){
strError +=" !You must enter a Password ! ";}
if((strPassword != strPassword2)){
strError +=" !The Password confirmation you entered is not correct ! ";}
if (strError.length() < 0)
{
RequestDispatcher rd = req.getRequestDispatcher("../servlet/register?Name=" + strName +
"&Email" + strEmail + "&Phone"+ strPhone + "&PostCode" + strPostCode +"&Password" + strPassword);
rd.forward(req, res);
}
else
{
out.println("error"
res.sendRedirect("../servlet/register.jsp?Name=" +strName +
"&Email" + strEmail + "&Phone"+ strPhone + "&PostCode" + strPostCode);
}
out.println("</body>"
out.println("</html>"
}
public void doPost(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException {
doGet(req, res);
}
}
The jsp page submits the values to a vailidateRegister servlet which then if the form fields contain relevent data it directs it on to another servlet which then stores the details in a database. However, even with relevent data in fields it redirects me back to the register.jsp (form) page and does not submit data to the insert servlet
hope this is enough description
any ideas
heres the code for the validation servlet (where i think the problem is)
import java.io.*;
import java.sql.*;
import java.lang.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class validateRegister extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
String strName = req.getParameter("Name"
String strEmail = req.getParameter("Email"
String strPhone = req.getParameter("Phone"
String strPassword = req.getParameter("Password"
String strPassword2 = req.getParameter("Password2"
String strPostCode = req.getParameter("PostCode"
String strError = "";
PrintWriter out = res.getWriter();
out.println("<html>"
out.println("<boby>"
if ((strName == null) || (strName.length() == 0)){
strError +=" !You must enter a valid Name ! ";}
if ((strEmail == null) || (strEmail.length() == 0)){
strError +=" !You must enter a valid Email ! ";}
if ((strPhone == null) || (strPhone.length() == 0)){
strError +=" !You must enter a valid Phone Number ! ";}
if((strPassword == null) || (strPassword.length() == 0)){
strError +=" !You must enter a Password ! ";}
if((strPassword != strPassword2)){
strError +=" !The Password confirmation you entered is not correct ! ";}
if (strError.length() < 0)
{
RequestDispatcher rd = req.getRequestDispatcher("../servlet/register?Name=" + strName +
"&Email" + strEmail + "&Phone"+ strPhone + "&PostCode" + strPostCode +"&Password" + strPassword);
rd.forward(req, res);
}
else
{
out.println("error"
res.sendRedirect("../servlet/register.jsp?Name=" +strName +
"&Email" + strEmail + "&Phone"+ strPhone + "&PostCode" + strPostCode);
}
out.println("</body>"
out.println("</html>"
}
public void doPost(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException {
doGet(req, res);
}
}