2 Replies Latest reply on Jun 4, 2009 2:00 PM by visakh m

    JBoss Seam Validation Problems

    visakh m Newbie
      Action files arunme88


      package demo.action;


      import java.sql.PreparedStatement;
      import java.sql.SQLException;

      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;

      import org.apache.struts.action.Action;
      import org.apache.struts.action.ActionForm;
      import org.apache.struts.action.ActionForward;
      import org.apache.struts.action.ActionMapping;
      import org.apache.struts.action.ActionMessage;
      import org.apache.struts.action.ActionMessages;
      import org.apache.struts.action.DynaActionForm;


      public class AddDAction extends Action
      {
        public ActionForward execute(
          ActionMapping mapping,
          ActionForm form,
          HttpServletRequest request,
          HttpServletResponse response) throws Exception{

          DynaActionForm f = (DynaActionForm)form;

          //Create object of ActionMesssages
              ActionMessages errors = new ActionMessages();
          //Check and collect errors
              if(((String)f.get("deptname")).equals("")) {
               errors.add("deptname",new ActionMessage("error.name.required"));
              }

              if(((String)f.get("deptid")).equals("")) {
               errors.add("deptid",new ActionMessage("error.address.required"));
              }

           
          //Saves the error
          saveErrors(request,errors);
          //Forward the page
          if(errors.isEmpty()){
               
               
               try
              {
             
              javax.sql.DataSource dataSource;
              java.sql.Connection myConnection=null;
             
            
                  
                
             
               dataSource = getDataSource(request);
               myConnection = dataSource.getConnection();
              
              String deptid=(String)f.get("deptid");
              int id=Integer.parseInt(deptid);
              String deptname=(String)f.get("deptname");
              
               PreparedStatement stmt=myConnection.prepareStatement("insert into department values(?,?);");
               stmt.setInt(2,id);
               stmt.setString(1,deptname);
               stmt.executeUpdate();
              }
              catch (SQLException sqle)
              {
               getServlet().log("Connection.process", sqle);
              }
             
               
               
          return mapping.findForward("success");
          }else{
          return mapping.findForward("invalid");
          }
         
         
         
          }
         
         
         
        }



      ---------------another one---



      package demo.action;

      /**
      * @author Deepak Kumar
      * @Web http://www.roseindia.net
      * @Email roseindia_net@yahoo.com
      */

      import java.sql.PreparedStatement;
      import java.sql.SQLException;

      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;

      import org.apache.struts.action.Action;
      import org.apache.struts.action.ActionForm;
      import org.apache.struts.action.ActionForward;
      import org.apache.struts.action.ActionMapping;
      import org.apache.struts.action.ActionMessage;
      import org.apache.struts.action.ActionMessages;
      import org.apache.struts.action.DynaActionForm;


      public class AddEAction extends Action
      {
        public ActionForward execute(
          ActionMapping mapping,
          ActionForm form,
          HttpServletRequest request,
          HttpServletResponse response) throws Exception{

          DynaActionForm f = (DynaActionForm)form;

          //Create object of ActionMesssages
              ActionMessages errors = new ActionMessages();
          //Check and collect errors
              if(((String)f.get("empid")).equals("")) {
               errors.add("empid",new ActionMessage("error.name.required"));
              }

              if(((String)f.get("empname")).equals("")) {
               errors.add("empname",new ActionMessage("error.address.required"));
              }
              if(((String)f.get("deptid")).equals("")) {
                  errors.add("deptid",new ActionMessage("error.name.required"));
                 }

                 if(((String)f.get("address")).equals("")) {
                  errors.add("address",new ActionMessage("error.address.required"));
                 }
                 if(((String)f.get("ph")).equals("")) {
                     errors.add("ph",new ActionMessage("error.name.required"));
                    }

           
          //Saves the error
          saveErrors(request,errors);
          //Forward the page
          if(errors.isEmpty()){
               
               
               try
              {
             
              javax.sql.DataSource dataSource;
              java.sql.Connection myConnection=null;
             
            
                  
                
             
               dataSource = getDataSource(request);
               myConnection = dataSource.getConnection();
              
              String deptid=(String)f.get("deptid");
              int idd=Integer.parseInt(deptid);
              String empid=(String)f.get("empid");
              int ide=Integer.parseInt(empid);
              String ph=(String)f.get("ph");
              int phe=Integer.parseInt(ph);
             
             
              String empname=(String)f.get("empname");
              String address=(String)f.get("empname");
             
             
             
             
             
              
               PreparedStatement stmt=myConnection.prepareStatement("insert into employee values(?,?,?,?,?);");
               stmt.setInt(1,ide);
               stmt.setString(2,empname);
               stmt.setInt(3,idd);
               stmt.setString(4,address);
               stmt.setInt(5,phe);
              
               stmt.executeUpdate();
              }
              catch (SQLException sqle)
              {
               getServlet().log("Connection.process", sqle);
              }
             
               
               
          return mapping.findForward("success");
          }
          else
          {
          return mapping.findForward("invalid");
          }
         
         
         
          }
         
         
         
        }



      ---------------   Another one---------------

      package demo.action;



      import java.sql.PreparedStatement;
      import java.sql.SQLException;

      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;

      import org.apache.struts.action.Action;
      import org.apache.struts.action.ActionForm;
      import org.apache.struts.action.ActionForward;
      import org.apache.struts.action.ActionMapping;
      import org.apache.struts.action.ActionMessage;
      import org.apache.struts.action.ActionMessages;
      import org.apache.struts.action.DynaActionForm;


      public class AddUAction extends Action
      {
        public ActionForward execute(
          ActionMapping mapping,
          ActionForm form,
          HttpServletRequest request,
          HttpServletResponse response) throws Exception{

          DynaActionForm f = (DynaActionForm)form;

          //Create object of ActionMesssages
              ActionMessages errors = new ActionMessages();
          //Check and collect errors
              if(((String)f.get("userid")).equals("")) {
               errors.add("userid",new ActionMessage("error.name.required"));
              }

              if(((String)f.get("password")).equals("")) {
               errors.add("password",new ActionMessage("error.address.required"));
              }
              if(((String)f.get("usertype")).equals("")) {
                  errors.add("usertype",new ActionMessage("error.name.required"));
                 }



           
          //Saves the error
          saveErrors(request,errors);
          //Forward the page
          if(errors.isEmpty()){
               
               
               try
              {
             
              javax.sql.DataSource dataSource;
              java.sql.Connection myConnection=null;
             
            
                  
                
             
               dataSource = getDataSource(request);
               myConnection = dataSource.getConnection();
              
              String deptid=(String)f.get("userid");
              int idu=Integer.parseInt(deptid);
             
             
             
              String password=(String)f.get("password");
              String usertype=(String)f.get("usertype");
             
             
             
             
             
              
               PreparedStatement stmt=myConnection.prepareStatement("insert into user values(?,?,?);");
               stmt.setInt(1,idu);
               stmt.setString(2,password);
               stmt.setString(3,usertype);
              
               stmt.executeUpdate();
              }
              catch (SQLException sqle)
              {
               getServlet().log("Connection.process", sqle);
              }
             
               
               
          return mapping.findForward("success");
          }
          else
          {
          return mapping.findForward("invalid");
          }
         
         
         
          }
         
         
         
        }

      -----------------Another One-----------------



        • 1. Re: JBoss Seam Validation Problems
          visakh m Newbie
          Other codes

          package demo.action;

          /**
          * @author Deepak Kumar
          * @Web http://www.roseindia.net
          * @Email roseindia_net@yahoo.com
          */

          import java.sql.PreparedStatement;
          import java.sql.SQLException;

          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;

          import org.apache.struts.action.Action;
          import org.apache.struts.action.ActionForm;
          import org.apache.struts.action.ActionForward;
          import org.apache.struts.action.ActionMapping;
          import org.apache.struts.action.ActionMessage;
          import org.apache.struts.action.ActionMessages;
          import org.apache.struts.action.DynaActionForm;


          public class DeleteDAction extends Action
          {
            public ActionForward execute(
              ActionMapping mapping,
              ActionForm form,
              HttpServletRequest request,
              HttpServletResponse response) throws Exception{

           

                   
                   try
                  {
                 
                  javax.sql.DataSource dataSource;
                  java.sql.Connection myConnection=null;
                 
                    
                 
                   dataSource = getDataSource(request);
                   myConnection = dataSource.getConnection();
                  
                  
                        
                  String idd=request.getParameter("radio");
                  int rd=Integer.parseInt(idd);
                 
                 
                   PreparedStatement stmt=myConnection.prepareStatement("delete from department where deptid=?");
               
                   stmt.setInt(1,rd);
                   stmt.executeUpdate();
                  }
                  catch (SQLException sqle)
                  {
                   getServlet().log("Connection.process", sqle);
                  }
                 
                   
                   
              return mapping.findForward("success");
             
              }
             
             
             
              }
             
             
             
           
          ---------- Another code----------

          package demo.action;

           
          import java.sql.PreparedStatement;
          import java.sql.ResultSet;

          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;
          import javax.servlet.http.HttpSession;

          import org.apache.struts.action.ActionForm;
          import org.apache.struts.action.ActionForward;
          import org.apache.struts.action.ActionMapping;
          import org.apache.struts.actions.DispatchAction;

          import demo.form.Department;
          import demo.form.Employee;
          import demo.form.User;




          public class DLoginAction extends DispatchAction
           

          {
            

          public ActionForward add(
              ActionMapping mapping,
              ActionForm form,
              HttpServletRequest request,
              HttpServletResponse response) throws Exception{
              System.out.println("You are in add function.");
                return mapping.findForward("add");
            }

           

          public ActionForward edit(
              ActionMapping mapping,
              ActionForm form,
              HttpServletRequest request,
              HttpServletResponse response) throws Exception

          {


               try
              {
             
             
              javax.sql.DataSource dataSource;
              java.sql.Connection myConnection=null;
            
                 /*  Department d =(Department)form;
                     String id=d.getDeptid();
                     int id1=Integer.parseInt(id);  */
             
               String id=request.getParameter("radio");
                int id1=Integer.parseInt(id);
            
               System.out.println(id);
               dataSource = getDataSource(request);
               myConnection = dataSource.getConnection();
              
               PreparedStatement stmt=myConnection.prepareStatement("select * from department where deptid=? ");
               stmt.setInt(1,id1);
              
               ResultSet rs=stmt.executeQuery();
            
                    
               Department newd  = new Department();                 
                    
                  while(rs.next())
                    {                     
                         String deptname=rs.getString(1);
                         String deptid=rs.getString(2);
                         
                         newd.setDeptname(deptname);
                         newd.setDeptid(deptid);
                         
                         System.out.println(deptid);
                         System.out.println(deptname);
                         
                    }
                 
                    HttpSession session=request.getSession();
                    session.setAttribute("newd",newd);
               
              }
               catch(Exception e)
               {
                    
               }
            System.out.println("You are in edit function.");
            return mapping.findForward("edit");

          }

            

          public ActionForward delete(
              ActionMapping mapping,
              ActionForm form,
              HttpServletRequest request,
              HttpServletResponse response) throws Exception{
               
               try
                    {
                    javax.sql.DataSource dataSource;
                   java.sql.Connection myConnection=null;
                         dataSource = getDataSource(request);
                         myConnection = dataSource.getConnection();
                         
                         /*   Department d =(Department)form;
                              String id=d.getDeptid();
                              int id2=Integer.parseInt(id);     */
                         
                          String id=request.getParameter("radio");
                          int id2=Integer.parseInt(id);
                         
                          System.out.println("martin");
                          System.out.println(id);
                         
                         
                          PreparedStatement stmt=myConnection.prepareStatement("delete  from department where deptid=? ");
                         stmt.setInt(1,id2);
                          int rows=stmt.executeUpdate();
                          System.out.println(rows);
              }catch (Exception sqle)
                {
                    getServlet().log("Connection.process",sqle);
                }
              
               return mapping.findForward("delete");
              }



          public ActionForward addh(
                   ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response) throws Exception{
                   System.out.println("You are in search function");
                   return mapping.findForward("addh");
                

                }

          public ActionForward edith(
                   ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response) throws Exception{
               
               
               
               try
              {
             
             
              javax.sql.DataSource dataSource;
              java.sql.Connection myConnection=null;
            
                 /*  Department d =(Department)form;
                     String id=d.getDeptid();
                     int id1=Integer.parseInt(id);  */
             
               String id=request.getParameter("radio");
                int id2=Integer.parseInt(id);
            
               System.out.println(id);
               dataSource = getDataSource(request);
               myConnection = dataSource.getConnection();
              
               PreparedStatement stmt=myConnection.prepareStatement("select * from employee where empid=? ");
               stmt.setInt(1,id2);
              
               ResultSet rs=stmt.executeQuery();
            
                    
               Employee d  = new Employee();                 
                    
                  while(rs.next())
                    {                     
                         String empid=rs.getString(1);
                         String empname=rs.getString(2);
                         String deptid=rs.getString(3);
                         String address=rs.getString(4);
                         String ph=rs.getString(5);
                         
                         d.setEmpid(empid);
                         d.setEmpname(empname);
                         d.setDeptid(deptid);
                         d.setAddress(address);
                         d.setPh(ph);
                         
                         
                    }
                 
                    HttpSession session=request.getSession();
                    session.setAttribute("d",d);
               
              }
               catch(Exception e)
               {
                    
               }
               
               
               
               
               
               
                   System.out.println("You are in search function");
                   return mapping.findForward("edith");
                }
           
          public ActionForward deleteh(
                   ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response) throws Exception{
               
               
               try
               {
               javax.sql.DataSource dataSource;
              java.sql.Connection myConnection=null;
                    dataSource = getDataSource(request);
                    myConnection = dataSource.getConnection();
                    
                    /*   Department d =(Department)form;
                         String id=d.getDeptid();
                         int id2=Integer.parseInt(id);     */
                    
                     String id=request.getParameter("radio");
                     int id3=Integer.parseInt(id);
                    
                    
                    
                    
                     PreparedStatement stmt=myConnection.prepareStatement("delete  from employee where empid=? ");
                    stmt.setInt(1,id3);
                     stmt.executeUpdate();
                    
          }catch (Exception sqle)
            {
                getServlet().log("Connection.process",sqle);
            }

               
               
                   System.out.println("You are in search function");
                   return mapping.findForward("deleteh");
                

                }







          public ActionForward editu(
                   ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response) throws Exception{
               
               
               
               try
              {
             
             
              javax.sql.DataSource dataSource;
              java.sql.Connection myConnection=null;
            
                 /*  Department d =(Department)form;
                     String id=d.getDeptid();
                     int id1=Integer.parseInt(id);  */
             
               String id=request.getParameter("radio");
                int id3=Integer.parseInt(id);
            
               System.out.println(id);
               dataSource = getDataSource(request);
               myConnection = dataSource.getConnection();
              
               PreparedStatement stmt=myConnection.prepareStatement("select * from user where userid=? ");
               stmt.setInt(1,id3);
              
               ResultSet rs=stmt.executeQuery();
            
                    
               User u  = new User();                 
                    
                  while(rs.next())
                    {                     
                         String userid=rs.getString(1);
                         String password=rs.getString(2);
                         String usertype=rs.getString(3);
                         
                         
                         u.setUserid(userid);
                         u.setPassword(password);
                         u.setUsertype(usertype);
                         
                         
                         
                    }
                 
                    HttpSession session=request.getSession();
                    session.setAttribute("u",u);
               
              }
               catch(Exception e)
               {
                    
               }
               
               

               
                   System.out.println("You are in search function");
                   return mapping.findForward("editu");
                }
           




          public ActionForward user(
                   ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response) throws Exception{
               
                   System.out.println("You are in search function");
                   return mapping.findForward("user");
                

                }




          public ActionForward logout(
                   ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response) throws Exception{
               
                   System.out.println("You are in search function");
                   return mapping.findForward("logout");
                

                }




          public ActionForward deleteu(
                   ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response) throws Exception{
               
               
               try
               {
               javax.sql.DataSource dataSource;
              java.sql.Connection myConnection=null;
                    dataSource = getDataSource(request);
                    myConnection = dataSource.getConnection();
                    
                    /*   Department d =(Department)form;
                         String id=d.getDeptid();
                         int id2=Integer.parseInt(id);     */
                    
                     String id=request.getParameter("radio");
                     int id3=Integer.parseInt(id);
                    
                    
                    
                    
                     PreparedStatement stmt=myConnection.prepareStatement("delete  from user where userid=? ");
                    stmt.setInt(1,id3);
                     stmt.executeUpdate();
                    
          }catch (Exception sqle)
            {
                getServlet().log("Connection.process",sqle);
            }

               
               
                   System.out.println("You are in search function");
                   return mapping.findForward("deleteu");
                

                }

          public ActionForward addu(
                   ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response) throws Exception{
                   System.out.println("You are in search function");
                   return mapping.findForward("addu");
                

                }




          }
           


          ----------Another one-------------------


          package demo.action;

          /**
          * @author Deepak Kumar
          * @Web http://www.roseindia.net
          * @Email roseindia_net@yahoo.com
          */

          import java.sql.PreparedStatement;
          import java.sql.SQLException;

          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;

          import org.apache.struts.action.Action;
          import org.apache.struts.action.ActionForm;
          import org.apache.struts.action.ActionForward;
          import org.apache.struts.action.ActionMapping;
          import org.apache.struts.action.ActionMessage;
          import org.apache.struts.action.ActionMessages;
          import org.apache.struts.action.DynaActionForm;


          public class EditDAction extends Action
          {
            public ActionForward execute(
              ActionMapping mapping,
              ActionForm form,
              HttpServletRequest request,
              HttpServletResponse response) throws Exception{

              DynaActionForm f = (DynaActionForm)form;

                   
                   try
                  {
                 
                  javax.sql.DataSource dataSource;
                  java.sql.Connection myConnection=null;
                 
                    
                 
                   dataSource = getDataSource(request);
                   myConnection = dataSource.getConnection();
                  
                  
                 String deptid=(String)f.get("deptid");
                  int id=Integer.parseInt(deptid);
                 
                  String deptname=(String)f.get("deptname");
                 
                       
                 
                   PreparedStatement stmt=myConnection.prepareStatement("update department set deptname=? where deptid=?");
                   stmt.setString(1,deptname);
                   stmt.setInt(2,id);
                 
                   stmt.executeUpdate();
                 
                  }
                  catch (SQLException sqle)
                  {
                   getServlet().log("Connection.process", sqle);
                  }
                 
                   
                   
              return mapping.findForward("success");
             
              }
             
             
             
              }
             
             
             
           
          -----------Another one--------------------

          package demo.action;

          /**
          * @author Deepak Kumar
          * @Web http://www.roseindia.net
          * @Email roseindia_net@yahoo.com
          */

          import java.sql.PreparedStatement;
          import java.sql.SQLException;

          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;

          import org.apache.struts.action.Action;
          import org.apache.struts.action.ActionForm;
          import org.apache.struts.action.ActionForward;
          import org.apache.struts.action.ActionMapping;
          import org.apache.struts.action.ActionMessage;
          import org.apache.struts.action.ActionMessages;
          import org.apache.struts.action.DynaActionForm;


          public class EditEAction extends Action
          {
            public ActionForward execute(
              ActionMapping mapping,
              ActionForm form,
              HttpServletRequest request,
              HttpServletResponse response) throws Exception{

              DynaActionForm f = (DynaActionForm)form;

              //Create object of ActionMesssages
                  ActionMessages errors = new ActionMessages();
              //Check and collect errors
                  if(((String)f.get("empid")).equals("")) {
                   errors.add("empid",new ActionMessage("error.name.required"));
                  }

                  if(((String)f.get("empname")).equals("")) {
                   errors.add("empname",new ActionMessage("error.address.required"));
                  }
                  if(((String)f.get("deptid")).equals("")) {
                      errors.add("deptid",new ActionMessage("error.name.required"));
                     }

                     if(((String)f.get("address")).equals("")) {
                      errors.add("address",new ActionMessage("error.address.required"));
                     }
                     if(((String)f.get("ph")).equals("")) {
                         errors.add("ph",new ActionMessage("error.name.required"));
                        }

               
              //Saves the error
              saveErrors(request,errors);
              //Forward the page
              if(errors.isEmpty()){
                   
                   
                   try
                  {
                 
                  javax.sql.DataSource dataSource;
                  java.sql.Connection myConnection=null;
                 
                
                      
                    
                 
                   dataSource = getDataSource(request);
                   myConnection = dataSource.getConnection();
                  
                  String deptid=(String)f.get("deptid");
                  int idd=Integer.parseInt(deptid);
                  String empid=(String)f.get("empid");
                  int ide=Integer.parseInt(empid);
                  String ph=(String)f.get("ph");
                  int phe=Integer.parseInt(ph);
                 
                 
                  String empname=(String)f.get("empname");
                  String address=(String)f.get("address");
                 
                 
                 
                  System.out.println("************************");
                  System.out.println(ide);
                  System.out.println(empname);
                  System.out.println(idd);
                  System.out.println(address);
                  System.out.println(phe);
                   
                  System.out.println("************************");
                 
                 
                 
                  
                   PreparedStatement stmt=myConnection.prepareStatement("update employee set empname=?, deptid=?, address=?, ph=? where empid=?");
                  
                   stmt.setString(1,empname);
                   stmt.setInt(2,idd);
                   stmt.setString(3,address);
                   stmt.setInt(4,phe);
                   stmt.setInt(5,ide);
                  
                   stmt.executeUpdate();
                  
                
                  }
                  catch (SQLException sqle)
                  {
                   getServlet().log("Connection.process", sqle);
                  }
                 
                   
                   
              return mapping.findForward("success");
              }
              else
              {
              return mapping.findForward("invalid");
              }
             
             
             
              }
             
             
             
            }


          ---------Another One-----------


          package demo.action;

          /**
          * @author Deepak Kumar
          * @Web http://www.roseindia.net
          * @Email roseindia_net@yahoo.com
          */

          import java.sql.PreparedStatement;
          import java.sql.SQLException;

          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;

          import org.apache.struts.action.Action;
          import org.apache.struts.action.ActionForm;
          import org.apache.struts.action.ActionForward;
          import org.apache.struts.action.ActionMapping;
          import org.apache.struts.action.ActionMessage;
          import org.apache.struts.action.ActionMessages;
          import org.apache.struts.action.DynaActionForm;


          public class EditUAction extends Action
          {
            public ActionForward execute(
              ActionMapping mapping,
              ActionForm form,
              HttpServletRequest request,
              HttpServletResponse response) throws Exception{

              DynaActionForm f = (DynaActionForm)form;

              //Create object of ActionMesssages
                  ActionMessages errors = new ActionMessages();
              //Check and collect errors
                  if(((String)f.get("userid")).equals("")) {
                   errors.add("userid",new ActionMessage("error.name.required"));
                  }

                  if(((String)f.get("password")).equals("")) {
                   errors.add("password",new ActionMessage("error.address.required"));
                  }
                  if(((String)f.get("usertype")).equals("")) {
                      errors.add("usertype",new ActionMessage("error.name.required"));
                     }

               
              //Saves the error
              saveErrors(request,errors);
              //Forward the page
              if(errors.isEmpty()){
                   
                   
                   try
                  {
                 
                  javax.sql.DataSource dataSource;
                  java.sql.Connection myConnection=null;
                 
                
                      
                    
                 
                   dataSource = getDataSource(request);
                   myConnection = dataSource.getConnection();
                  
                  String userid=(String)f.get("userid");
                  int idu=Integer.parseInt(userid);
                 
                 
                 
                  String password=(String)f.get("password");
                  String usertype=(String)f.get("usertype");
                 
                 
                 
                  System.out.println("************************");
                  System.out.println(idu);
                  System.out.println(password);
                  System.out.println(usertype);
                   
                  System.out.println("************************");
                 
                 
                 
                  
                   PreparedStatement stmt=myConnection.prepareStatement("update user set  password=? where userid=?");
                  
                   stmt.setString(1,password);
                   stmt.setInt(2,idu);
                  
                   stmt.executeUpdate();
                  
                
                  }
                  catch (SQLException sqle)
                  {
                   getServlet().log("Connection.process", sqle);
                  }
                 
                   
                   
              return mapping.findForward("success");
              }
              else
              {
              return mapping.findForward("invalid");
              }
             
             
             
              }
             
             
             
            }

          ------------Another one-----------


          package demo.action;

          import java.sql.PreparedStatement;
          import java.sql.ResultSet;
          import java.sql.SQLException;
          import java.util.ArrayList;

          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;
          import javax.servlet.http.HttpSession;

          import org.apache.struts.action.Action;
          import org.apache.struts.action.ActionForm;
          import org.apache.struts.action.ActionForward;
          import org.apache.struts.action.ActionMapping;

          import demo.form.Department;
          import demo.form.Employee;
          import demo.form.NewLoginForm;
          import demo.form.User;

          public class NewLoginAction extends Action
          {
               String flag=null;
               ResultSet rst;
            public ActionForward execute(
              ActionMapping mapping,
              ActionForm form,
              HttpServletRequest request,
              HttpServletResponse response) throws Exception
              {
                 javax.sql.DataSource dataSource;
                 java.sql.Connection myConnection=null;
                
                 try
                 {
                     
                   NewLoginForm o=(NewLoginForm)form;
                  int useId=Integer.parseInt(o.getUseId());
                  String password=o.getPassword();
                  dataSource = getDataSource(request);
                 
                  myConnection = dataSource.getConnection();
                  PreparedStatement stmt=myConnection.prepareStatement("select * from user where userid=? and password=?");
                  stmt.setInt(1,useId);
                  stmt.setString(2,password);
                  rst=stmt.executeQuery();
                 
                  if(rst.next())
                  {     
                         if( rst.getString(3).equals("admin"))
                        {     
                             flag="admin";<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
          <%@ taglib uri="/tags/struts-html" prefix="html" %>
          <html:html locale="true">
          <body>
          <html:form  method="post" action="/EditE">
          <table>
          <tr>
          <td>Employee Id:</td><td> <html:text property="empid" value="" size="30" maxlength="30"/></td>
          </tr>
          <tr>
          <td>Employee Name: </td><td><html:text property="empname" value="" size="30" maxlength="30"/></td>
          </tr>
          <tr>
          <td>Department Id: </td><td><html:text property="deptid" value="" size="30" maxlength="30"/></td>
          </tr>
          <tr>
          <td>Address: </td><td><html:text property="address" value="" size="30" maxlength="30"/></td>
          </tr>
          <tr>
          <td>Ph: </td><td><html:text property="ph" size="30" value="" maxlength="30"/></td>
          </tr>
          </table>
          <html:submit>Edit</html:submit><br>
          <html:reset>Reset</html:reset><br>
          </html:form>
          </body>
          </html:html>
                             
                             
                             
                           dataSource = getDataSource(request);
                          myConnection = dataSource.getConnection();
                          PreparedStatement stm=myConnection.prepareStatement("select * from department");
                         ResultSet rs=stm.executeQuery();
                        
                     ArrayList l=new ArrayList();   
                    
                     while(rs.next())
                     {
                          Department b=new Department();
                          b.setDeptname(rs.getString(1));
                          b.setDeptid(rs.getString(2));
                         
                          l.add(b);
                         
                         
                     }
                    
                     HttpSession session=request.getSession(true);
                     session.setAttribute("l",l);
                             
                             
                    
                    
                    
                    
             
                    
                     PreparedStatement st=myConnection.prepareStatement("select * from user ");
                       
                    ResultSet rss=st.executeQuery();
                      
                   ArrayList arr=new ArrayList();   
                  
                   while(rss.next())
                   {
                        User b=new User();
                        b.setUserid(rss.getString(1));
                        b.setPassword(rss.getString(2));
                        b.setUsertype(rss.getString(3));
                     
                        arr.add(b);
                       
                        System.out.println(rss.getString(1));
                        System.out.println(rss.getString(2));
                        System.out.println(rss.getString(3));
                   }
                  
                  
                   session.setAttribute("arr",arr);
                         
                    
                
                    
                    
                             
                        }
                       
                       else if( rst.getString(3).equals("user"))
                        {     
                       
                             flag="user";
                             
                             
                             
                             String id=request.getParameter("useId");
                               int id1=Integer.parseInt(id);
                             
                           
                           
                             dataSource = getDataSource(request);
                            myConnection = dataSource.getConnection();
                            PreparedStatement stm=myConnection.prepareStatement("select * from user where userid=? ");
                            stm.setInt(1,id1);
                           ResultSet rs=stm.executeQuery();
                          
                       ArrayList ar=new ArrayList();   
                      
                       while(rs.next())
                       {
                            User b=new User();
                            b.setUserid(rs.getString(1));
                            b.setPassword(rs.getString(2));
                            b.setUsertype(rs.getString(3));
                         
                            ar.add(b);
                           
                            System.out.println(rs.getString(1));
                            System.out.println(rs.getString(2));
                            System.out.println(rs.getString(3));
                       }
                      
                       HttpSession session=request.getSession(true);
                       session.setAttribute("ar",ar);
                             
                       
                      
                      
           
                             
                        }
                        else
                        {
                             flag="hr";
                             
                             
                             dataSource = getDataSource(request);
                           myConnection = dataSource.getConnection();
                           PreparedStatement stm=myConnection.prepareStatement("select * from employee ");
                          ResultSet rs=stm.executeQuery();
                         
                      ArrayList a=new ArrayList();   
                     
                      while(rs.next())
                      {
                           Employee b=new Employee();
                           b.setEmpid(rs.getString(1));
                           b.setEmpname(rs.getString(2));
                           b.setDeptid(rs.getString(3));
                          b.setAddress(rs.getString(4));
                         b.setPh(rs.getString(5));
                        
                           a.add(b);
                          
                           System.out.println(rs.getString(1));
                           System.out.println(rs.getString(2));
                           System.out.println(rs.getString(3));
                      }
                     
                      HttpSession session=request.getSession(true);
                      session.setAttribute("a",a);
                              
                             
                             
                        }                               
                       
                       
                 }
                  else
                  {
                       flag="error";
                  }
                 
                 }
               
                 catch (SQLException sqle)
                 {
                  getServlet().log("Connection.process", sqle);
                 }
                 finally
                 {
                         
                 try
                 {
                     
                     myConnection.close();
                  }
                 catch (SQLException e)
                 {
                     getServlet().log("Connection.close", e);
                  }
                 }
                
                 if(flag.equals("admin"))
                 { 
                     return mapping.findForward("admin");
                 }
                 else if(flag.equals("hr"))
                 {
                      return mapping.findForward("hr");
                 }
                 else if(flag.equals("user"))
                 {
                         return mapping.findForward("user");
                    }
                 else
                         return mapping.findForward("error");

              }
          }
                

               
           

          -------------------Ends---------------------------------------------


          • 2. Re: JBoss Seam Validation Problems
            visakh m Newbie
            ----A Form Bean-----------

            package demo.form;

            import org.apache.struts.action.ActionForm;


            public class Department extends ActionForm
            {
                 
              private String deptname;
              private String deptid;
              private String dispatch;
              public String getDispatch()
              {
                  return this.dispatch;
                   }

              public void setDispatch(String parameter)
             
              {
                this.dispatch=parameter;
               }
             
              public void setDeptname(String deptname)
              {
                this.deptname=deptname;
              }

              public String getDeptname()
              {
                return this.deptname;
              }

              public void setDeptid(String deptid)
              {
                this.deptid=deptid;
              }

              public String getDeptid()
              {
                return this.deptid;
              }

            }


            ------------edit.jsp------------------

            <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
            <%@ taglib uri="/tags/struts-html" prefix="html" %>

            <html:html locale="true">

            <body>

            <%@ page language="java" import="demo.form.Department "%>
            <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
            <%@ taglib uri="/tags/struts-html" prefix="html" %>


            <% Department ulfrm=(Department)session.getAttribute("newd");
            out.println(ulfrm.getDeptname());
            out.println(ulfrm.getDeptid());

            String deptid=ulfrm.getDeptid();
            String deptname=ulfrm.getDeptname();
            %>


            <html:form  method="post" action="/EditD" onsubmit="return validateEditDForm(this);">

            <table>
            <tr>
            <td>Department Name:</td><td> <html:text property="deptname" value="<%=deptname%>" size="30" maxlength="30"/></td>
            </tr>

            <% /* <bean:write name="ulfrm" property="deptname" /> */ %>

            <tr>
            <td>Department Id: </td><td><html:text property="deptid" value="<%=deptid%>" size="30" maxlength="30"/></td>
            </tr>

            <% /* <bean:write name="ulfrm" property="deptid" /> */ %>

            </table>
                      
            <html:submit>Edit</html:submit><br>

            <html:javascript formName="EditDForm"/>

            </html:form>


            </body>
            </html:html>


            ---------------addu.jsp--------------------


            <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
            <%@ taglib uri="/tags/struts-html" prefix="html" %>

            <html:html locale="true">

            <body >
            <html:form  method="post" action="/AddU" onsubmit="return validateAddUForm(this);">

            <table>
            <tr>
            <td>User Id:</td><td> <html:text property="userid" size="30" maxlength="30"/></td>
            </tr>
            <tr>
            <td>Password: </td><td><html:text property="password" size="30" maxlength="30"/></td>
            </tr>
            <tr>
            <td>User Type: </td><td><html:text property="usertype" size="30" maxlength="30"/></td>
            </tr>


            </table>
            <html:submit>Add</html:submit><br>

            <html:javascript formName="AddUForm"/>

            </html:form>
            </body>
            </html:html>



            --------------delete.jsp-----------------


            <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
            <%@ taglib uri="/tags/struts-html" prefix="html" %>

            <html:html locale="true">

            <body>
            <%@ page language="java" import="java.sql.*"%>
            <%
            String rd=request.getParameter("radio"); 

            %>
            <html:form  method="post" action="/DeleteD">

            <table>
            <tr>
            <td>Are u sure to delete Department id:</td><td> <html:text property="rad" value="<%=rd%>" size="30" maxlength="30"/></td>
            </tr>


            </table>
            <html:submit>Delete</html:submit><br>

            </html:form>
            </body>
            </html:html>


            ------------template.jsp-------------

            <%@ page language="java" %>
            <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
            <html>

            <head>
                <title><tiles:getAsString name="title" ignore="true"/></title>
                <link href="/Martin2/pages/s.css" type="text/css" rel="StyleSheet">
            </head>

            <body>

            <table id="t" border="1" cellpadding="0" cellspacing="0" width="100%" bordercolor="#000000" bgcolor="#E7FDFE">
            <tr>
            <td width="100%" colspan="2" valign="top"><tiles:insert attribute="header"/></td>
            </tr>
            <tr>
            <td width="100%" valign="top" valign="top"><tiles:insert attribute="body"/></td>
            </tr>

            </table>

            </body>

            </html>




            ----------------template1.jsp------------

            <%@ page language="java" %>
            <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
            <html>

            <head>
                <title><tiles:getAsString name="title" ignore="true"/></title>
               
            <link href="/Martin2/pages/s.css" type="text/css" rel="StyleSheet">

            </head>

            <body>

            <table id="t1" border="1" cellpadding="0" cellspacing="0" width="100%" bordercolor="#000000" bgcolor="#E7FDFE">
            <tr>
            <td width="100%" colspan="2" valign="top"><tiles:insert attribute="header"/></td>
            </tr>
            <tr>
            <td width="50%" valign="top" valign="top"><tiles:insert attribute="menu"/></td>
            <td width="50%" valign="top" valign="top"><tiles:insert attribute="body"/></td>
            </tr>

            </table>

            </body>

            </html>



            ----------------------------------


            strutsconfig.xml


            <?xml version="1.0" encoding="ISO-8859-1" ?>

            <!DOCTYPE struts-config PUBLIC
                      "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
                      "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">

            <!--
                 This is a blank Struts configuration file with an example
                 welcome action/page and other commented sample elements.

                 Tiles and the Struts Validator are configured using the factory defaults
                 and are ready-to-use.

                 NOTE: If you have a generator tool to create the corresponding Java classes
                 for you, you could include the details in the "form-bean" declarations.
                 Otherwise, you would only define the "form-bean" element itself, with the
                 corresponding "name" and "type" attributes, as shown here.
            -->


            <struts-config>

            <!-- ============================================ Data Source Configuration -->

            <data-sources>
            <data-source type="org.apache.commons.dbcp.BasicDataSource">
                <set-property
                  property="driverClassName"
                  value="com.mysql.jdbc.Driver" />
                <set-property
                  property="url"
                  value="jdbc:mysql://192.168.2.79:3306/martin?autoReconnect=true" />
                <set-property
                  property="username"
                  value="sprint" />
                <set-property
                  property="password"
                  value="student" />
                <set-property
                  property="maxActive"
                  value="10" />
                <set-property
                  property="maxWait"
                  value="5000" />
                <set-property
                  property="defaultAutoCommit"
                  value="true" />
                <set-property
                  property="defaultReadOnly"
                  value="false" />

            </data-source>
            </data-sources>


            <!-- ================================================ Form Bean Definitions -->

                <form-beans>
               
                <!-- sample form bean descriptor for an ActionForm
                    <form-bean
                        name="inputForm"
                        type="app.InputForm"/>
                end sample -->

                <!-- sample form bean descriptor for a DynaActionForm
                    <form-bean
                        name="logonForm"
                        type="org.apache.struts.action.DynaActionForm">
                        <form-property
                            name="username"
                            type="java.lang.String"/>
                        <form-property
                            name="password"
                            type="java.lang.String"/>
                   </form-bean>
                end sample -->
              
              
              
            <form-bean
                  name="NewLoginForm"
                  type="demo.form.NewLoginForm"/>
                 
                 

                      
            <form-bean name="Department"
                       type="demo.form.Department"/> 
                      
                      
                      
                       <form-bean name="Employee"
                       type="demo.form.Employee"/> 
                      
                      
                       <form-bean name="User"
                       type="demo.form.User"/>
                      
                      
                     <form-bean name="AddDForm"  
                     type="org.apache.struts.action.DynaActionForm">
                     <form-property name="deptname" type="java.lang.String"/>
                     <form-property name="deptid" type="java.lang.String"/>
                     </form-bean>  
                
                
                 
                 
                     <form-bean name="EditDForm"  
                     type="org.apache.struts.action.DynaActionForm">
                     <form-property name="deptname" type="java.lang.String"/>
                     <form-property name="deptid" type="java.lang.String"/>
                     </form-bean>  
                    
                    
                    
                    
                      <form-bean name="DeleteDForm"  
                     type="org.apache.struts.action.DynaActionForm">
                     <form-property name="deptname" type="java.lang.String"/>
                     <form-property name="deptid" type="java.lang.String"/>
                     </form-bean>
                    
                   <form-bean name="AddEForm"  
                     type="org.apache.struts.action.DynaActionForm">
                    
                     <form-property name="empid" type="java.lang.String"/>
                     <form-property name="empname" type="java.lang.String"/>
                     <form-property name="deptid" type="java.lang.String"/>
                     <form-property name="address" type="java.lang.String"/>
                     <form-property name="ph" type="java.lang.String"/>
              
                     </form-bean>  
             
             
             
              <form-bean name="EditEForm"  
                     type="org.apache.struts.action.DynaActionForm">
                    
                     <form-property name="empid" type="java.lang.String"/>
                     <form-property name="empname" type="java.lang.String"/>
                     <form-property name="deptid" type="java.lang.String"/>
                     <form-property name="address" type="java.lang.String"/>
                     <form-property name="ph" type="java.lang.String"/>
              
                     </form-bean>
                    
                    
                    
                    
                     <form-bean name="AddUForm"  
                     type="org.apache.struts.action.DynaActionForm">
                    
                     <form-property name="userid" type="java.lang.String"/>
                     <form-property name="password" type="java.lang.String"/>
                     <form-property name="usertype" type="java.lang.String"/>
                     </form-bean>  
                    
                    
                    
                    
                     <form-bean name="EditUForm"  
                     type="org.apache.struts.action.DynaActionForm">
                     <form-property name="userid" type="java.lang.String"/>
                     <form-property name="password" type="java.lang.String"/>
                     <form-property name="usertype" type="java.lang.String"/>
                     </form-bean> 
             
            </form-beans>
              
              


            <!-- ========================================= Global Exception Definitions -->

                <global-exceptions>
                    <!-- sample exception handler
                    <exception
                        key="expired.password"
                        type="app.ExpiredPasswordException"
                        path="/changePassword.jsp"/>
                    end sample -->
                </global-exceptions>


            <!-- =========================================== Global Forward Definitions -->

                <global-forwards>
                    <!-- Default forward to "Welcome" action -->
                    <!-- Demonstrates using index.jsp to forward -->
                    <forward
                        name="welcome"
                        path="/Welcome.do"/>
                </global-forwards>


            <!-- =========================================== Action Mapping Definitions -->

                <action-mappings>
                    <!-- Default "Welcome" action -->
                        <!-- Forwards to Welcome.jsp -->
                    <action
                        path="/Welcome"
                        forward="/Tiles/Example.do"/>

                <!-- sample input and input submit actions

                    <action
                        path="/Input"
                        type="org.apache.struts.actions.ForwardAction"
                        parameter="/pages/Input.jsp"/>

                    <action
                        path="/InputSubmit"
                        type="app.InputAction"
                        name="inputForm"
                        scope="request"
                        validate="true"
                        input="/pages/Input.jsp"/>

                        <action
                            path="/edit*"
                            type="app.Edit{1}Action"
                            name="inputForm"
                            scope="request"
                            validate="true"
                            input="/pages/Edit{1}.jsp"/>

                end samples -->
               
                 <action
                  path="/TestAction"
                  type="demo.action.TestAction">
                  <forward name="testAction" path="/pages/TestAction.jsp"/>
               </action> 
              
               <action path="/Tiles/Example"
                   forward="Tiles.Example"/>
              
               <action path="/Tiles1/Example"
                   forward="Tiles1.Example"/>
              
               <action path="/Tiles11/Example"
                   forward="Tiles11.Example"/>
              
               <action path="/Tiles12/Example"
                   forward="Tiles12.Example"/>
              
                   <action path="/Tiles13/Example"
                   forward="Tiles13.Example"/>  

                 <action path="/Tiles14/Example"
                   forward="Tiles14.Example"/>


            <action path="/Tiles15/Example"
                   forward="Tiles15.Example"/>
                  
                   <action path="/Tiles16/Example"
                   forward="Tiles16.Example"/>

            <action path="/Tiles17/Example"
                   forward="Tiles17.Example"/>


            <action path="/Tiles18/Example"
                   forward="Tiles18.Example"/>

            <action path="/Tiles19/Example"
                   forward="Tiles19.Example"/>

            <action path="/Tiles20/Example"
                   forward="Tiles20.Example"/>

            <action path="/Tiles21/Example"
                   forward="Tiles21.Example"/>

            <action path="/Tiles22/Example"
                   forward="Tiles22.Example"/>

            <action
                 path="/NewLogin"
                 type="demo.action.NewLoginAction"
                 name="NewLoginForm"
                 scope="request"
                 validate="true"
                 input="/pages/NewLogin.jsp">

                <forward name="hr" path="/Tiles1/Example.do"/>
                <forward name="admin" path="/Tiles11/Example.do"/>
                <forward name="user" path="/Tiles12/Example.do"/>
                <forward name="error" path="/Tiles22/Example.do"/>
            </action>
              
              
              
              
              
              
            <action
            path="/DispatchUser"
            type="demo.action.DLoginAction"
            parameter="dispatch"
            input="/pages/menuad.jsp"
            name="Department"
            scope="session"
            validate="false">
            <forward name="user" path="/Tiles13/Example.do"/>
            </action>
              
             
             
             
             
             
              <action
            path="/DispatchLogout"
            type="demo.action.DLoginAction"
            parameter="dispatch"
            input="/pages/menuad.jsp"
            name="Department"
            scope="session"
            validate="false">
            <forward name="logout" path="/Tiles/Example.do"/>
            </action>
             
              
              
              
              
              
               <action
            path="/DispatchAction"
            type="demo.action.DLoginAction"
            parameter="dispatch"
            input="/pages/admin.jsp"
            name="Department"
            scope="session"
            validate="false">

            <forward name="add" path="/Tiles14/Example.do"/>
            <forward name="edit" path="/Tiles15/Example.do"/>
            <forward name="delete" path="/Tiles16/Example.do"/>
            </action>
              
              
              
            <action
            path="/DispatchActionE"
            type="demo.action.DLoginAction"
            parameter="dispatch"
            input="/pages/hr.jsp"
            name="Employee"
            scope="request"
            validate="false">

            <forward name="addh" path="/Tiles17/Example.do"/>
            <forward name="edith" path="/Tiles18/Example.do"/>
            <forward name="deleteh" path="/Tiles16/Example.do"/>

            </action>
              

            <action
            path="/DispatchActionU"
            type="demo.action.DLoginAction"
            parameter="dispatch"
            input="/pages/menuad.jsp"
            name="User"
            scope="request"
            validate="false">


            <forward name="addu" path="/Tiles19/Example.do"/>
            <forward name="editu" path="/Tiles20/Example.do"/>
            <forward name="deleteu" path="/Tiles16/Example.do"/>


            </action>

              
              
              
               <action path="/AddD" type="demo.action.AddDAction"
                 name="AddDForm"
                 scope="request"
                 validate="true"
                 input="/pages/add.jsp">

                <forward name="success" path="/Tiles21/Example.do"/>
                <forward name="invalid" path="/pages/DynaAddress.jsp" />

               </action>
              
              
              
              
              
              
             
               <action path="/EditD" type="demo.action.EditDAction"
                 name="EditDForm"
                 scope="request"
                 validate="true"
                 input="/pages/edit.jsp">

                <forward name="success" path="/Tiles21/Example.do"/>
                <forward name="invalid" path="/pages/DynaAddress.jsp" />
               </action>
              
              
              
               <action path="/DeleteD" type="demo.action.DeleteDAction"
                 name="DeleteDForm"
                 scope="request"
                 validate="true"
                 input="/pages/admin.jsp">

               <forward name="success" path="/Tiles21/Example.do"/>
                <forward name="invalid" path="/pages/DynaAddress.jsp" />
               </action>
              
              
               <action path="/AddE" type="demo.action.AddEAction"
                 name="AddEForm"
                 scope="request"
                 validate="true"
                 input="/pages/addh.jsp">

                <forward name="success" path="/Tiles21/Example.do"/>
                <forward name="invalid" path="/pages/DynaAddress.jsp" />

               </action>
              
              
              
              
              
              
               <action path="/AddU" type="demo.action.AddUAction"
                 name="AddUForm"
                 scope="request"
                 validate="true"
                 input="/pages/addu.jsp">

                <forward name="success" path="/Tiles21/Example.do"/>
                <forward name="invalid" path="/pages/DynaAddress.jsp" />

               </action>
              
              
              
              
              
              
               <action path="/EditE" type="demo.action.EditEAction"
                 name="EditEForm"
                 scope="request"
                 validate="true"
                 input="/pages/edith.jsp">

               <forward name="success" path="/Tiles21/Example.do"/>
                <forward name="invalid" path="/pages/DynaAddress.jsp" />

               </action>
              
               <action path="/EditU" type="demo.action.EditUAction"
                 name="EditUForm"
                 scope="request"
                 validate="true"
                 input="/pages/editu.jsp">

               <forward name="success" path="/Tiles21/Example.do"/>
                <forward name="invalid" path="/pages/DynaAddress.jsp" />

               </action>
              
              
                
                </action-mappings>


            <!-- ============================================= Controller Configuration -->

                <controller
                   processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>


            <!-- ======================================== Message Resources Definitions -->

                <message-resources parameter="demo.MessageResources" />


            <!-- =============================================== Plug Ins Configuration -->

              <!-- ======================================================= Tiles plugin -->
              <!--
                 This plugin initialize Tiles definition factory. This later can takes some
                  parameters explained here after. The plugin first read parameters from
                  web.xml, thenoverload them with parameters defined here. All parameters
                  are optional.
                 The plugin should be declared in each struts-config file.
                   - definitions-config: (optional)
                        Specify configuration file names. There can be several comma
                          separated file names (default: ?? )
                   - moduleAware: (optional - struts1.1)
                        Specify if the Tiles definition factory is module aware. If true
                        (default), there will be one factory for each Struts module.
                           If false, there will be one common factory for all module. In this
                        later case, it is still needed to declare one plugin per module.
                        The factory will be initialized with parameters found in the first
                        initialized plugin (generally the one associated with the default
                        module).
                             true : One factory per module. (default)
                             false : one single shared factory for all modules
                    - definitions-parser-validate: (optional)
                         Specify if xml parser should validate the Tiles configuration file.
                             true : validate. DTD should be specified in file header (default)
                             false : no validation

                   Paths found in Tiles definitions are relative to the main context.
              -->

                <plug-in className="org.apache.struts.tiles.TilesPlugin" >

                  <!-- Path to XML definition file -->
                  <set-property property="definitions-config"
                                   value="/WEB-INF/tiles-defs.xml" />
                  <!-- Set Module-awareness to true -->
                  <set-property property="moduleAware" value="true" />
                </plug-in>


              <!-- =================================================== Validator plugin -->

            <!--  Validator plugin -->
            <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
                      <set-property
                        property="pathnames"
                       value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
            </plug-in>

            </struts-config>








            ----------------tilesdefn.xml--------------------------------


            <?xml version="1.0" encoding="ISO-8859-1" ?>

            <!DOCTYPE tiles-definitions PUBLIC
                   "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
                   "http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">


            <!--
                 This is a blank Tiles definition file with a commented example.
            -->

            <tiles-definitions>
                 <definition name="Tiles.Example" page="/pages/template.jsp">
                      <put name="title" type="string" value="Welcome" />
                     
                      <put name="header" value="/pages/top.jsp" />
                      <put name="body" value="/pages/NewLogin.jsp" />
                 </definition>










               <definition name="Tiles1.Example" page="/pages/template1.jsp">
                      <put name="title" type="string" value="Welcome" />
                     
                      <put name="header" value="/pages/top.jsp" />
                      <put name="menu" value="/pages/martin.jsp" />
                      <put name="body" value="/pages/hr.jsp" />
                     
                 </definition>




                 <definition name="Tiles11.Example" extends="Tiles1.Example">
                      <put name="menu" value="/pages/menuad.jsp" />
                      <put name="body" value="/pages/admin.jsp" />    
                 </definition>


                 <definition name="Tiles12.Example" extends="Tiles1.Example">
                      <put name="body" value="/pages/user.jsp" />    
                 </definition>


            <definition name="Tiles13.Example" extends="Tiles1.Example">
                      <put name="body" value="/pages/adminuser.jsp" />
                      <put name="menu" value="/pages/menuad.jsp" />   
                 </definition>

            <definition name="Tiles14.Example" extends="Tiles1.Example">
            <put name="menu" value="/pages/menuad.jsp" />
                      <put name="body" value="/pages/add.jsp" />
            </definition>
                     
            <definition name="Tiles15.Example" extends="Tiles1.Example">
            <put name="menu" value="/pages/menuad.jsp" />
                      <put name="body" value="/pages/edit.jsp" />
            </definition>
                         
            <definition name="Tiles16.Example" extends="Tiles1.Example">
                      <put name="body" value="/pages/success.jsp" />
            </definition>            
                
            <definition name="Tiles17.Example" extends="Tiles1.Example">
                      <put name="body" value="/pages/addh.jsp" />
            </definition>

            <definition name="Tiles18.Example" extends="Tiles1.Example">
                      <put name="body" value="/pages/edith.jsp" />
            </definition>

            <definition name="Tiles19.Example" extends="Tiles1.Example">
                      <put name="body" value="/pages/addu.jsp" />
            </definition>

            <definition name="Tiles20.Example" extends="Tiles1.Example">
                      <put name="body" value="/pages/editu.jsp" />
            </definition>

            <definition name="Tiles21.Example" extends="Tiles1.Example">
                      <put name="body" value="/pages/success.jsp" />
            </definition>

            <definition name="Tiles22.Example" extends="Tiles1.Example">
                      <put name="body" value="/pages/error.jsp" />
                      <put name="menu" value="/pages/null.jsp" />
            </definition>








                <!-- sample tiles definitions
                <definition name=".mainLayout" path="/common/layouts/classicLayout.jsp">
                    <put name="title"  value="Sample Page Title" />
                    <put name="header" value="/common/header.jsp" />
                    <put name="menu"   value=".mainMenu" />
                    <put name="footer" value="/common/footer.jsp" />
                    <put name="body"   value=".portal.body" />
                </definition>

                <definition name=".mainMenu" path="/common/layouts/vboxLayout.jsp" >
                    <putList name="list" >
                        <add value=".menu.links" />
                        <add value=".menu.taglib.references" />
                        <add value=".menu.printer.friendly" />
                        <add value=".menu.old.documents" />
                  </putList>
                </definition>

                <definition name="aPage" extends=".mainLayout">
                    <put name="title"  value="Another Title" />
                    <put name="body"   value=".aPage.body" />
                </definition>

                end samples -->

                <definition name="${YOUR_DEFINITION_HERE}">
                </definition>

            </tiles-definitions>




            ---------------web.xml------------------------




            <?xml version="1.0" encoding="ISO-8859-1"?>

            <!DOCTYPE web-app
              PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
              "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

            <web-app>
              <display-name>Struts Blank Application</display-name>
             
              <!-- Standard Action Servlet Configuration (with debugging) -->
              <servlet>
                <servlet-name>action</servlet-name>
                <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
                <init-param>
                  <param-name>config</param-name>
                  <param-value>/WEB-INF/struts-config.xml</param-value>
                </init-param>
                <init-param>
                  <param-name>debug</param-name>
                  <param-value>2</param-value>
                </init-param>
                <init-param>
                  <param-name>detail</param-name>
                  <param-value>2</param-value>
                </init-param>
                <load-on-startup>2</load-on-startup>
              </servlet>


              <!-- Standard Action Servlet Mapping -->
              <servlet-mapping>
                <servlet-name>action</servlet-name>
                <url-pattern>*.do</url-pattern>
              </servlet-mapping>


              <!-- The Usual Welcome File List -->
              <welcome-file-list>
                <welcome-file>index.jsp</welcome-file>
              </welcome-file-list>


              <!-- Struts Tag Library Descriptors -->
              <taglib>
                <taglib-uri>/tags/struts-bean</taglib-uri>
                <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
              </taglib>

              <taglib>
                <taglib-uri>/tags/struts-html</taglib-uri>
                <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
              </taglib>

              <taglib>
                <taglib-uri>/tags/struts-logic</taglib-uri>
                <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
              </taglib>

              <taglib>
                <taglib-uri>/tags/struts-nested</taglib-uri>
                <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
              </taglib>

              <taglib>
                <taglib-uri>/tags/struts-tiles</taglib-uri>
                <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
              </taglib>

            </web-app>




            --------------------------------