Did you restart the application? I believe that config file gets loaded at startup.
- Glenn On Mon, May 5, 2008 at 10:25 AM, Raghu varma bhupathiraju < [EMAIL PROTECTED]> wrote: > > Hi I have the following application done successfully with out validation > > HomePage.jsp > ////////////////////// > <%@ taglib uri="/tags/struts-bean" prefix="bean" %> > <%@ taglib uri="/tags/struts-html" prefix="html" %> > <%@ taglib uri="/tags/struts-logic" prefix="logic" %> > > <[EMAIL PROTECTED] import="java.sql.*"%> > <html:html locale="true"> > <script> > function set(){ > > var count=document.forms[0].status.length; > > document.forms[0].avalues.value=""; > > for(var i=0;i<count;i++){ > if(document.forms[0].status[i].checked==true){ > document.forms[0].status[i].value="checked"; > }else{ > document.forms[0].status[i].value="ignore"; > } > > > > document.forms[0].avalues.value+=document.forms[0].status[i].value+" "; > > } > > > } > </script> > > <head> > > <html:base/> > > </head> > <%!Connection con=null; > Statement stmt=null; > ResultSet rs=null;%> > <% try{ > Class.forName("com.mysql.jdbc.Driver"); > Connection > > con=DriverManager.getConnection("jdbc:mysql://localhost:3306/raghu","root","root"); > stmt=con.createStatement(); > String str="select uname from users"; > rs=stmt.executeQuery(str); > } > catch(Exception ex){ > ex.printStackTrace(); > } > %> > > > > <body bgcolor="white"> > <html:form action="/process"> > <center><h3><bean:message key="welcome.heading"/></h3></center><br> > <center> > <table ><tr><td><html:submit property="parameter" value="addUser" > /> </td> > <td><html:select property="action"> > <option value="">select</option> > <option value="delete">Delete</option> > </html:select> </td> > <td><html:submit property="parameter" value="Go" onclick="set()" /></td> > </tr></table></center> > <center> > <table> > <% if(rs!=null){ > while(rs.next()){%> > <tr><td> > <html:checkbox property="status" styleId="status" styleId="status" > value="unchecked"/></td><td></td><td></td><td></td><td></td><td></td> > <td><html:link action="/process3?user=<%=rs.getString(1).toString()%>" > ><%=rs.getString(1)%></html:link></td></tr> > <%}}else{}%> > </table> > <html:hidden property="avalues" styleId="avalues" /> > </center> > </html:form> > </body> > </html:html> > ///////////////////////// > Config file > > <?xml version="1.0" encoding="ISO-8859-1" ?> > > <!DOCTYPE struts-config PUBLIC > "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" > "http://jakarta.apache.org/struts/dtds/struts-config_1_1.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> > > <set-property > > property="autoCommit" > > value="false"/> > > <set-property > > property="description" > > value="Example Data Source Configuration"/> > > <set-property > > property="driverClass" > > value="org.postgresql.Driver"/> > > <set-property > > property="maxCount" > > value="4"/> > > <set-property > > property="minCount" > > value="2"/> > > <set-property > > property="password" > > value="mypassword"/> > > <set-property > > property="url" > > value="jdbc:postgresql://localhost/mydatabase"/> > > <set-property > > property="user" > > value="myusername"/> > > </data-source> > > </data-sources> > > --> > > > > <!-- ======================================== Form Bean Definitions --> > > > > <form-beans> > > > > > > <form-bean > > name="inputForm" > > type="com.bob.StrutsTask.TaskForm"/> > > > > > > > > <!-- 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"/> > > end sample --> > > > > </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 --> > > > </global-forwards> > > > > > > <!-- =================================== Action Mapping Definitions --> > > > > <action-mappings> > > > > <!-- Default "Welcome" action --> > > <!-- Forwards to Welcome.jsp --> > > <action > path="/process" name="inputForm" > > type="com.bob.StrutsTask.StrutsAction" parameter="parameter" > > input="/pages/HomePage.jsp" > > <forward name="add" path="/pages/add.jsp"/> > <forward name="success" path="/pages/HomePage.jsp"/> > <forward name="failed" path="/pages/HomePage.jsp"/> > </action> > <action > path="/process2" name="inputForm" > > type="com.bob.StrutsTask.StrutsAction" parameter="parameter" > > input="/pages/add.jsp" > > <forward name="success" path="/pages/HomePage.jsp"/> > </action> > <action > path="/process3" name="inputForm" > > type="com.bob.StrutsTask.UserAction" > > input="/pages/HomePage.jsp"> > <forward name="success" path="/pages/add.jsp"/> > </action> > > </action-mappings> > > > > > > <!-- ===================================== Controller Configuration --> > > > > <controller > > processorClass="org.apache.struts.tiles.TilesRequestProcessor"/> > > > > > > <!-- ================================ Message Resources Definitions --> > > > > <message-resources parameter="java.resources.application"/> > > > > > > <!-- ======================================= 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, then > overload 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. > --> > <!-- comment following if struts1.0.x --> > <plug-in className="org.apache.struts.tiles.TilesPlugin" > > <set-property property="definitions-config" > value="/WEB-INF/tiles-defs.xml" /> > <set-property property="moduleAware" value="true" /> > <set-property property="definitions-parser-validate" value="true" /> > </plug-in> > > <!-- end comment if struts1.0.x --> > > <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> > > //////// > TaskForm.java > package com.bob.StrutsTask; > > > import org.apache.struts.action.ActionForm; > > > public class TaskForm extends ActionForm{ > String parameter=""; > String action=""; > String uname=""; > String password=""; > String repassword=""; > String role=""; > String fname=""; > String lname=""; > String company=""; > String email=""; > String phone=""; > String baddress=""; > String saddress=""; > String bcity=""; > String scity=""; > String bstate=""; > String sstate=""; > String bzip=""; > String szip=""; > String bcountry=""; > String scountry=""; > String status[]; > String user=""; > String avalues=""; > public String getAction() { > return action; > } > public void setAction(String action) { > this.action = action; > } > > public String getCompany() { > return company; > } > public void setCompany(String company) { > this.company = company; > } > public String getEmail() { > return email; > } > public void setEmail(String email) { > this.email = email; > } > public String getFname() { > return fname; > } > public void setFname(String fname) { > this.fname = fname; > } > public String getLname() { > return lname; > } > public void setLname(String lname) { > this.lname = lname; > } > public String getParameter() { > return parameter; > } > public void setParameter(String parameter) { > this.parameter = parameter; > } > public String getPassword() { > return password; > } > public void setPassword(String password) { > this.password = password; > } > public String getPhone() { > return phone; > } > public void setPhone(String phone) { > this.phone = phone; > } > > public String getRole() { > return role; > } > public void setRole(String role) { > this.role = role; > } > > public String getUname() { > return uname; > } > public void setUname(String uname) { > this.uname = uname; > } > public String getBaddress() { > return baddress; > } > public void setBaddress(String address) { > baddress = address; > } > public String getBcity() { > return bcity; > } > public void setBcity(String bcity) { > this.bcity = bcity; > } > public String getBcountry() { > return bcountry; > } > public void setBcountry(String bcountry) { > this.bcountry = bcountry; > } > public String getBstate() { > return bstate; > } > public void setBstate(String bstate) { > this.bstate = bstate; > } > public String getBzip() { > return bzip; > } > public void setBzip(String bzip) { > this.bzip = bzip; > } > public String getRepassword() { > return repassword; > } > public void setRepassword(String repassword) { > this.repassword = repassword; > } > public String getSaddress() { > return saddress; > } > public void setSaddress(String saddress) { > this.saddress = saddress; > } > public String getScity() { > return scity; > } > public void setScity(String scity) { > this.scity = scity; > } > public String getScountry() { > return scountry; > } > public void setScountry(String scountry) { > this.scountry = scountry; > } > public String getSstate() { > return sstate; > } > public void setSstate(String sstate) { > this.sstate = sstate; > } > public String getSzip() { > return szip; > } > public void setSzip(String szip) { > this.szip = szip; > } > public String[] getStatus() { > return status; > } > public void setStatus(String[] status) { > this.status = status; > } > public String getUser() { > return user; > } > public void setUser(String user) { > this.user = user; > } > > public String getAvalues() { > return avalues; > } > public void setAvalues(String avalues) { > this.avalues = avalues; > } > > > } > ////////// > Action class > package com.bob.StrutsTask; > > import java.sql.Connection; > > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpServletResponse; > > import org.apache.struts.action.ActionForm; > import org.apache.struts.action.ActionForward; > import org.apache.struts.action.ActionMapping; > import org.apache.struts.actions.DispatchAction; > > public class StrutsAction extends DispatchAction { > > public ActionForward addUser(ActionMapping mapping, ActionForm > form, > HttpServletRequest request, HttpServletResponse response) throws Exception > { > > > return mapping.findForward("add"); > } > > public ActionForward Go(ActionMapping mapping, ActionForm form, > HttpServletRequest request, HttpServletResponse response) throws Exception > { > TaskForm tform=(TaskForm)form; > System.out.println("entered into action"); > UserDetails udetails=new UserDetails(); > Connection con=udetails.getConnection(); > System.out.println("entered into action2"); > String status=udetails.deleteUsers(tform,con); > return mapping.findForward("success"); > } > > public ActionForward SaveUser(ActionMapping mapping, ActionForm > form, > HttpServletRequest request, HttpServletResponse response) throws Exception > { > TaskForm tform=(TaskForm)form; > UserDetails udetails=new UserDetails(); > Connection con=udetails.getConnection(); > String status=udetails.saveData(tform,con); > return mapping.findForward(status); > } > > public ActionForward UpdateUser(ActionMapping mapping, ActionForm > form, > HttpServletRequest request, HttpServletResponse response) throws Exception > { > > TaskForm tform=(TaskForm)form; > UserDetails udetails=new UserDetails(); > Connection con=udetails.getConnection(); > String status=udetails.updateData(tform,con); > return mapping.findForward(status); > } > } > /// > UserDetails.java > package com.bob.StrutsTask; > import java.sql.Connection; > import java.sql.DriverManager; > import java.sql.PreparedStatement; > import java.sql.ResultSet; > import java.sql.SQLException; > import java.sql.Statement; > import java.util.ArrayList; > > import org.apache.struts.validator.DynaValidatorForm; > > public class UserDetails { > Connection con=null; > Statement stmt=null; > ResultSet rs=null; > ArrayList ar=null; > > public Connection getConnection(){ > try{ > Class.forName("com.mysql.jdbc.Driver"); > > > con=DriverManager.getConnection("jdbc:mysql://localhost:3306/raghu","root","root"); > }catch(Exception ex){ > con=null; > } > return con; > } > public ArrayList getUserDetails(String user,Connection con)throws > Exception{ > try{ > stmt=con.createStatement(); > System.out.println(user); > String str="select * from users where uname='"+user+"'"; > rs=stmt.executeQuery(str); > ar=new ArrayList(); > if(rs!=null){ > while(rs.next()){ > System.out.println(rs.getString(1).toString()); > System.out.println(rs.getString(2).toString()); > System.out.println(rs.getString(3).toString()); > > ar.add(rs.getString(1)); > ar.add(rs.getString(2)); > ar.add(rs.getString(3)); > ar.add(rs.getString(4)); > ar.add(rs.getString(5)); > ar.add(rs.getString(6)); > ar.add(rs.getString(7)); > ar.add(rs.getString(8)); > ar.add(rs.getString(9)); > ar.add(rs.getString(10)); > ar.add(rs.getString(11)); > ar.add(rs.getString(12)); > ar.add(rs.getString(13)); > ar.add(rs.getString(14)); > ar.add(rs.getString(15)); > ar.add(rs.getString(16)); > ar.add(rs.getString(17)); > ar.add(rs.getString(18)); > } > }else{ > System.out.println("result set is empty"); > } > }catch(SQLException sex){ > sex.printStackTrace(); > } > return ar; > } > public String saveData(TaskForm tform,Connection con){ > String status=""; > status="failed"; > String uname=tform.getUname().toString(); > String pswd=tform.getPassword().toString(); > String role=tform.getRole().toString(); > String fname=tform.getFname().toString(); > String lname=tform.getLname().toString(); > String company=tform.getCompany().toString(); > String email=tform.getEmail().toString(); > long phone=Long.parseLong(tform.getPhone().toString()); > String baddress=tform.getBaddress().toString(); > String saddress=tform.getSaddress().toString(); > String bcity=tform.getBcity().toString(); > String scity=tform.getScity().toString(); > String bstate=tform.getBstate().toString(); > String sstate=tform.getSstate().toString(); > String bzip=tform.getBzip().toString(); > String szip=tform.getSzip().toString(); > String bcountry=tform.getBcountry().toString(); > String scountry=tform.getScountry().toString(); > > > try{ > if(con!=null){ > > String fquery="select * from users where > uname='"+uname+"' and > pswd='"+pswd+"'"; > Statement stmt=con.createStatement(); > ResultSet rst=stmt.executeQuery(fquery); > > if(rst!=null){ > if(rst.next()){ > > > > > }else{ > > String query="insert into users > values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; > PreparedStatement > pstmt=con.prepareStatement(query); > pstmt.setString(1,uname); > pstmt.setString(2,pswd); > pstmt.setString(3,role); > pstmt.setString(4,fname); > pstmt.setString(5,lname); > pstmt.setString(6,company); > pstmt.setString(7,email); > pstmt.setLong(8,phone); > pstmt.setString(9,baddress); > pstmt.setString(10,saddress); > pstmt.setString(11,bcity); > pstmt.setString(12,scity); > pstmt.setString(13,bstate); > pstmt.setString(14,sstate); > pstmt.setString(15,bzip); > pstmt.setString(16,szip); > pstmt.setString(17,bcountry); > pstmt.setString(18,scountry); > > > pstmt.executeUpdate(); > > }} > status="success"; > > }}catch(Exception ex){ > ex.printStackTrace(); > } > return status; > } > > public String updateData(TaskForm tform,Connection con){ > String status="failed"; > > try{ > if(con!=null){ > String query="update users set > pswd=?,role=?,fname=?,lname=?,company=?,email=?,phone=?," + > " > > baddress=?,saddress=?,bcity=?,scity=?,bstate=?,sstate=?,bzip=?,szip=?,bcountry=?" > + > ",scountry=? where uname=?"; > PreparedStatement > pstmt=con.prepareStatement(query); > > pstmt.setString(1,tform.getPassword().toString()); > > pstmt.setString(2,tform.getRole().toString()); > > pstmt.setString(3,tform.getFname().toString()); > > pstmt.setString(4,tform.getLname().toString()); > > pstmt.setString(5,tform.getCompany().toString()); > > pstmt.setString(6,tform.getEmail().toString()); > > pstmt.setLong(7,Long.parseLong(tform.getPhone().toString())); > > pstmt.setString(8,tform.getBaddress().toString()); > > pstmt.setString(9,tform.getSaddress().toString()); > > pstmt.setString(10,tform.getBcity().toString()); > > pstmt.setString(11,tform.getScity().toString()); > > pstmt.setString(12,tform.getBstate().toString()); > > pstmt.setString(13,tform.getSstate().toString()); > > pstmt.setInt(14,Integer.parseInt(tform.getBzip().toString())); > > pstmt.setInt(15,Integer.parseInt(tform.getSzip().toString())); > > pstmt.setString(16,tform.getBcountry().toString()); > > pstmt.setString(17,tform.getScountry().toString()); > > pstmt.setString(18,tform.getUname().toString()); > > pstmt.executeUpdate(); > > status="success"; > }} > catch(Exception ex){ > ex.printStackTrace(); > } > > return status; > } > public String deleteUsers(TaskForm tform,Connection con){ > String status="failed"; > try{ > > String action=tform.getAction().toString(); > if(action.equalsIgnoreCase("delete")){ > String array=tform.getAvalues(); > String[] values=array.split(" "); > int count=values.length; > System.out.println(count); > > for(int i=0;i<count;i++){ > System.out.println(values[i]); > } > Statement > stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, > ResultSet.CONCUR_UPDATABLE); > > rs=stmt.executeQuery("select* from users"); > > int index=0; > while(rs.next()){ > > if(values[index].equalsIgnoreCase("checked")){ > rs.deleteRow(); > } > index++; > } > status="success"; > }else{ > status="failed"; > } > > > > }catch(SQLException ex){ > ex.printStackTrace(); > }catch(ArrayIndexOutOfBoundsException aex){ > aex.printStackTrace(); > } > > return status; > } > } > ////// > I run the program successfully but when i changed Action form to validator > form and inserted attribute > > validate="true" in config file.and populated validate.xml > > i m not getting error but > when i > tried to execute > > no action is trrigering in jsp > if i click add user or Go also no action is occuring > > Can i change Action form to validatore form in middle of application > if i change again to action form the application is working properly. > > Can any one help me in this regards > thanks in advance > Raghu varma bhupathiraju > > > -- > View this message in context: > http://www.nabble.com/Plz-help-not-getting-o-p-when-changed-to-validator-form-tp17062809p17062809.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >