Hey guys. I'm new to Struts and I hope u cud solve this prob. Cheers.
I developed a Registration.html file and I have an in the action servlet (Registeruser) and an action form called UserRegForm. Plz see whether the Action servlet and the action form need any changes or additions. If I hav to write a Registration class, wat would dat include?
Registration.html:
Registeruser Action Servlet:
java Code:
package org.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.*;
import javax.servlet.GenericServlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletConfig;
import javax.servlet.http.*;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
import java.io.*;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
public class Registeruser
extends Action {
// private String Mobile;
public ActionForward execute
(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response
) throws IOException, ServletException
{ String upno,uname,uaddress,upwd,dob, mob;
//String supno,suname,suaddress,supwd;
//PrintWriter out=response.getWriter();
//response.setContentType("text/html");
//out.println("<html><head></head><title></title><body bgcolor=\"#FFCCFF\">");
//out.println("<center><h1>YOUR REGISTRATION IS SUCCESSFULL<BR>PLEASE CHECK YOUR INFORMATION :</h1></center>");
//out.println("<form name=\"javanewuser\" >");
//out.println("<center><table width=200 height=200 border=3 bordercolor=\"white\">");
try
{
ServletContext ee=getServletConfig().getServletContext();
uname=request.getParameter("First_name");
upno=request.getParameter("Last_name");
uaddress=request.getParameter("Address");
dob=request.getParameter("Dob");
mob=request.getParameter("Mobile");
upwd=request.getParameter("Password");
String ssql=
"insert into userinfo values(?,?,?,?,?,?)";
pistmt.setString(1,uname);
pistmt.setString(2,upno);
pistmt.setString(3,uaddress);
pistmt.setString(4,dob);
pistmt.setString(5,mob);
pistmt.setString(6,upwd);
pistmt.executeUpdate();
return mapping.findForward("success");
{
//out.println(e);
return mapping.findForward("error");
}
/** Creates a new instance of Registeruser */
}
}
Action Form :
java Code:
package com.myapp.struts;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
public class UserRegForm extends ActionForm {
private String First_name =
null;
return (First_name);
}
public void setName
(String First_name
) { this.First_name = First_name;
}
}