Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts validation framework

 
Vineeta Nair
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

M trying to implement struts validation framework on form fields...But when i click on the submit button i m forwarded to the next page... no validation happens...Below is d code...When i try using Action errors validate method it is working...but when i use validation frame work m getting an exception in console...Below is d output in console....


Web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>LoginForm</display-name>
<servlet>
<display-name>ActionServlet</display-name>
<servlet-name>Login1</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>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<description>
</description>
<display-name>
LoginAction</display-name>
<servlet-name>LoginAction</servlet-name>
<servlet-class>
com.testing.LoginAction</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Login1</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>LoginAction</servlet-name>
<url-pattern>/LoginAction</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>Login.jsp</welcome-file>
</welcome-file-list>
<jsp-config></jsp-config>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
</web-app>

Struts-config.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>


<form-beans>

<form-bean name="LoginActionForm" type="com.testing.LoginActionForm"/>

</form-beans>
<action-mappings>
<action path="/LoginAction" type="com.testing.LoginAction" name="LoginActionForm" input= "Login.jsp"
scope="session" validate="true">
<forward name="success" path="/Welcome.jsp" />
<forward name="failure" path="/Error.jsp" />
</action>
</action-mappings>
<message-resources parameter="com.testing.ApplicationResource" />
<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>

Validation.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
<form-validation>
<formset>
<form name="LoginActionForm">
<field property="username" depends="required,maxlength,minlength,mask">

<msg name="required" key="error.LoginAction.username.required" />
<msg name="maxlength" key="error.LoginAction.username.length" />
<msg name="minlength" key="error.LoginAction.username.length" />
<msg name="mask" key="error.LoginAction.username.invalid" />

<arg name="maxlength" key="${var:minlength}" position="0" resource="false" />
<arg name="maxlength" key="${var:maxlength}" position="1" resource="false" />
<var>
<var-name>maxlength</var-name>
<var-value>15</var-value>
</var>

<arg name="minlength" key="${var:minlength}" position="0" resource="false" />
<arg name="minlength" key="${var:maxlength}" position="1" resource="false" />
<var>
<var-name>minlength</var-name>
<var-value>3</var-value>
</var>

<var>
<var-name>mask</var-name>
<var-value>^[a-zA-Z0-9-_]*$</var-value>
</var>
</field>
</form>
</formset>
</form-validation>


Validator-rules.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
<form-validation>
<global>
<validator
name="required"
classname="org.apache.struts.validator.FieldChecks"
method="validateRequired"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
msg="errors.required"/>

<validator name="minlength"
classname="org.apache.struts.validator.FieldChecks"
method="validateMinLength"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.minlength"/>

<validator name="maxlength"
classname="org.apache.struts.validator.FieldChecks"
method="validateMaxLength"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.maxlength"/>

<validator name="mask"
classname="org.apache.struts.validator.FieldChecks"
method="validateMask"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.invalid" />
</global>
</form-validation>

LoginAction.java
package com.testing;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
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.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


public class LoginAction extends Action
{
/*private final static String SUCCESS = "success";
private final static String FAILURE = "failure";*/
public ActionForward execute(ActionMapping mapping,ActionForm form,

HttpServletRequest request,HttpServletResponse response) throws Exception
{



System.out.println("--in action class--");


System.out.println("hi");


return mapping.findForward("success");

}
}
LoginActionForm.java
package com.testing;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.validator.ValidatorForm;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
public class LoginActionForm extends ValidatorForm {

private String username ;
private String color ;
private String sex ;
private String vehicle ;
private String location ;
public String getUsername()
{

return username;

}
public void setUsername(String username)
{

this.username = username;

}

public String getColor()
{

return color;

}
public void setColor(String color)
{

this.color = color;

}
public String getSex()
{

return sex;

}
public void setSex(String sex)
{

this.sex = sex;

}
public String getVehicle()
{

return vehicle;

}
public void setVehicle(String vehicle)
{

this.vehicle = vehicle;

}

public String getLocation()
{

return location;

}
public void setLocation(String location)
{

this.location = location;

}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {

ActionErrors errors = new ActionErrors();

if (getUsername() == null || getUsername().length() < 1) {

errors.add("username", new ActionMessage("error.username.required"));

}

if (getColor() == null || getColor().length() < 1) {

errors.add("color", new ActionMessage("error.color.required"));

}
if (getSex() == null || getSex().length() < 1) {

errors.add("sex", new ActionMessage("error.sex.required"));

}
if (getVehicle() == null || getVehicle().length() < 1) {

errors.add("vehicle", new ActionMessage("error.vehicle.required"));

}
if (getLocation() == null || getLocation().length() < 1) {

errors.add("location", new ActionMessage("error.location.required"));

}
return errors;


}
}

ApplicationResource.properties
error.username.required=User Name is required.<br/>
error.color.required=Color is required.<br/>
error.sex.required=Please select your choice.<br/>
error.vehicle.required=Please select your choice.<br/>
error.location.required=Please select your choice.<br/>
Login.jsp

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

<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>

<html:form action="LoginAction.do" method="post" onsubmit="return validateLoginActionForm(this)">



Username: <html:text property = "username" />

<html:errors property="username" /> <br><br>

<html:radio property="sex" value="Male"/>Male<br>
<html:radio property="sex" value="Female"/>Female<br>
<html:errors property="sex" /> <br><br>

<html:checkbox property="vehicle" value="I have a bike"/>I have a bike<br>
<html:checkbox property="vehicle" value="I have a car"/>I have a car<br>
<html:errors property="vehicle" /> <br><br>

Location:<html:select property="location" >

<htmlption value="Mumbai">Mumbai</htmlption>
<htmlption value="Delhi">Delhi</htmlption>
<htmlption value="Bangalore">Bangalore</htmlption>

</html:select><br/>
<html:errors property="location" /> <br><br>

What is your favourite color:<html:text property = "color" />

<html:errors property="color" /> <br><br>

<html:submit value="Submit"/>
<html:reset value="Reset" />

</html:form>

</body>
</html>


Welcome.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@page
language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Welcome</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%
String username=request.getParameter("username");
String color=request.getParameter("color");
String sex=request.getParameter("sex");
String vehicle=request.getParameter("vehicle");
String location=request.getParameter("location");
%>

</head>
<body>

Welcome <%= username %><br><br>
You are <%= sex %><br><br>
You have a <%= vehicle %><br><br>
Your location is <%= location %><br><br>
Your Favourite color is <%= color %>
</body>
</html>

Error.jsp

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@page
language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Error</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
Login Failed!
</body>
</html>

Console
[9/6/12 12:44:38:377 IST] 00000055 ValidatorForm E org.apache.struts.validator.ValidatorForm validate org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, org.apache.struts.action.ActionMessages, org.apache.commons.validator.Validator, javax.servlet.http.HttpServletRequest)
org.apache.commons.validator.ValidatorException: org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, org.apache.struts.action.ActionMessages, org.apache.commons.validator.Validator, javax.servlet.http.HttpServletRequest)
at org.apache.commons.validator.ValidatorAction.loadValidationMethod(ValidatorAction.java:627)
at org.apache.commons.validator.ValidatorAction.executeValidationMethod(ValidatorAction.java:557)
at org.apache.commons.validator.Field.validateForRule(Field.java:827)
at org.apache.commons.validator.Field.validate(Field.java:906)
at org.apache.commons.validator.Form.validate(Form.java:174)
at org.apache.commons.validator.Validator.validate(Validator.java:367)
at org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java:110)
at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:950)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:207)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1101)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:569)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3440)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:815)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1461)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:118)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:267)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)

[9/6/12 12:44:38:377 IST] 00000055 SystemOut O --in action class--
[9/6/12 12:44:38:377 IST] 00000055 SystemOut O hi
[9/6/12 12:44:38:471 IST] 00000055 ServletWrappe I SRVE0242I: [FirstTaskEAR] [/FirstTask] [/Welcome.jsp]: Initialization successful.






 
dhaval thakor
Ranch Hand
Posts: 53
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please do not write your whole code if not necessary.
 
Eswar Nec
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to use code tag, when you post.
its easy to identify the source code.
 
Vineeta Nair
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

M trying to implement struts validation framework on form fields...But when i click on the submit button i m forwarded to the next page... no validation happens...Any help would be appreciated...



<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">

<struts-config>


<form-beans>

<form-bean name="LoginActionForm" type="com.testing.LoginActionForm"/>

</form-beans>
<action-mappings>
<action path="/LoginAction" type="com.testing.LoginAction" name="LoginActionForm" input= "Login.jsp"
scope="session" validate="true">
<forward name="success" path="/Welcome.jsp" />
<forward name="failure" path="/Error.jsp" />
</action>
</action-mappings>
<message-resources parameter="com.testing.ApplicationResource" />
<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>



<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>LoginForm</display-name>
<servlet>
<display-name>ActionServlet</display-name>
<servlet-name>Login1</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>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<description>
</description>
<display-name>
LoginAction</display-name>
<servlet-name>LoginAction</servlet-name>
<servlet-class>
com.testing.LoginAction</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Login1</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>LoginAction</servlet-name>
<url-pattern>/LoginAction</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>Login.jsp</welcome-file>
</welcome-file-list>
<jsp-config></jsp-config>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
</web-app>



<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
<form-validation>
<formset>
<form name="LoginActionForm">
<field property="username" depends="required,maxlength,minlength,mask">

<msg name="required" key="error.LoginAction.username.required" />
<msg name="maxlength" key="error.LoginAction.username.length" />
<msg name="minlength" key="error.LoginAction.username.length" />
<msg name="mask" key="error.LoginAction.username.invalid" />

<arg name="maxlength" key="${var:minlength}" position="0" resource="false" />
<arg name="maxlength" key="${var:maxlength}" position="1" resource="false" />
<var>
<var-name>maxlength</var-name>
<var-value>15</var-value>
</var>

<arg name="minlength" key="${var:minlength}" position="0" resource="false" />
<arg name="minlength" key="${var:maxlength}" position="1" resource="false" />
<var>
<var-name>minlength</var-name>
<var-value>3</var-value>
</var>

<var>
<var-name>mask</var-name>
<var-value>^[a-zA-Z0-9-_]*$</var-value>
</var>
</field>
</form>
</formset>
</form-validation>





<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
<form-validation>
<global>
<validator
name="required"
classname="org.apache.struts.validator.FieldChecks"
method="validateRequired"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
msg="errors.required"/>

<validator name="minlength"
classname="org.apache.struts.validator.FieldChecks"
method="validateMinLength"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.minlength"/>

<validator name="maxlength"
classname="org.apache.struts.validator.FieldChecks"
method="validateMaxLength"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.maxlength"/>

<validator name="mask"
classname="org.apache.struts.validator.FieldChecks"
method="validateMask"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.invalid" />
</global>
</form-validation>




package com.testing;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
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.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


public class LoginAction extends Action
{
/*private final static String SUCCESS = "success";
private final static String FAILURE = "failure";*/
public ActionForward execute(ActionMapping mapping,ActionForm form,

HttpServletRequest request,HttpServletResponse response) throws Exception
{



System.out.println("--in action class--");


System.out.println("hi");


return mapping.findForward("success");

}
}



package com.testing;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.validator.ValidatorForm;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
public class LoginActionForm extends ValidatorForm {

private String username ;
private String color ;
private String sex ;
private String vehicle ;
private String location ;
public String getUsername()
{

return username;

}
public void setUsername(String username)
{

this.username = username;

}

public String getColor()
{

return color;

}
public void setColor(String color)
{

this.color = color;

}
public String getSex()
{

return sex;

}
public void setSex(String sex)
{

this.sex = sex;

}
public String getVehicle()
{

return vehicle;

}
public void setVehicle(String vehicle)
{

this.vehicle = vehicle;

}

public String getLocation()
{

return location;

}
public void setLocation(String location)
{

this.location = location;

}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {

ActionErrors errors = new ActionErrors();

if (getUsername() == null || getUsername().length() < 1) {

errors.add("username", new ActionMessage("error.username.required"));

}

if (getColor() == null || getColor().length() < 1) {

errors.add("color", new ActionMessage("error.color.required"));

}
if (getSex() == null || getSex().length() < 1) {

errors.add("sex", new ActionMessage("error.sex.required"));

}
if (getVehicle() == null || getVehicle().length() < 1) {

errors.add("vehicle", new ActionMessage("error.vehicle.required"));

}
if (getLocation() == null || getLocation().length() < 1) {

errors.add("location", new ActionMessage("error.location.required"));

}
return errors;


}
}




error.username.required=User Name is required.<br/>
error.color.required=Color is required.<br/>
error.sex.required=Please select your choice.<br/>
error.vehicle.required=Please select your choice.<br/>
error.location.required=Please select your choice.<br/>



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

<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>

<html:form action="LoginAction.do" method="post" onsubmit="return validateLoginActionForm(this)">



Username: <html:text property = "username" />

<html:errors property="username" /> <br><br>

<html:radio property="sex" value="Male"/>Male<br>
<html:radio property="sex" value="Female"/>Female<br>
<html:errors property="sex" /> <br><br>

<html:checkbox property="vehicle" value="I have a bike"/>I have a bike<br>
<html:checkbox property="vehicle" value="I have a car"/>I have a car<br>
<html:errors property="vehicle" /> <br><br>

Location:<html:select property="location" >

<htmlption value="Mumbai">Mumbai</htmlption>
<htmlption value="Delhi">Delhi</htmlption>
<htmlption value="Bangalore">Bangalore</htmlption>

</html:select><br/>
<html:errors property="location" /> <br><br>

What is your favourite color:<html:text property = "color" />

<html:errors property="color" /> <br><br>

<html:submit value="Submit"/>
<html:reset value="Reset" />

</html:form>

</body>
</html>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@page
language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Welcome</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%
String username=request.getParameter("username");
String color=request.getParameter("color");
String sex=request.getParameter("sex");
String vehicle=request.getParameter("vehicle");
String location=request.getParameter("location");
%>

</head>
<body>

Welcome <%= username %><br><br>
You are <%= sex %><br><br>
You have a <%= vehicle %><br><br>
Your location is <%= location %><br><br>
Your Favourite color is <%= color %>
</body>
</html>




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@page
language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Error</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
Login Failed!
</body>
</html>
 
Vineeta Nair
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have got the desired output now...

struts-config.xml

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
<form-bean name="loginForm" type="com.testing.LoginActionForm" />
</form-beans>
<action-mappings>
<action path="/Login" type="com.testing.LoginAction" name="loginForm" input="/Login.jsp">
<forward name="success" path="/Welcome.jsp" />
</action>
</action-mappings>


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

<message-resources parameter="com/myapp/struts/ApplicationResource"/>

<!-- ========================= 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" >
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
<set-property property="moduleAware" value="true" />
</plug-in>

<!-- ========================= 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>


Web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<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>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>Login.jsp</welcome-file>
</welcome-file-list>
<jsp-config>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>


Validation.xml
<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
<form-validation>
<formset>
<form name="loginForm">
<field property="username" depends="required,maxlength,minlength,mask">
<msg name="required" key="error.login.username.required" />
<msg name="maxlength" key="error.login.username.length" />
<msg name="minlength" key="error.login.username.length" />
<msg name="mask" key="error.login.username.invalid" />
<arg name="maxlength" key="${var:minlength}" position="0" resource="false" />
<arg name="maxlength" key="${var:maxlength}" position="1" resource="false" />
<var>
<var-name>maxlength</var-name>
<var-value>15</var-value>
</var>
<arg name="minlength" key="${var:minlength}" position="0" resource="false" />
<arg name="minlength" key="${var:maxlength}" position="1" resource="false" />
<var>
<var-name>minlength</var-name>
<var-value>3</var-value>
</var>
<var>
<var-name>mask</var-name>
<var-value>^[a-zA-Z0-9-_]*$</var-value>
</var>
</field>
<field property="color" depends="required">
<msg name="required" key="error.login.color.required" />

</field>
<field property="sex" depends="required">
<msg name="required" key="error.login.sex.required" />

</field>
<field property="vehicle" depends="required">
<msg name="required" key="error.login.vehicle.required" />

</field>
<field property="location" depends="required">
<msg name="required" key="error.login.location.required" />

</field>
</form>
</formset>
</form-validation>


Validator-rules.xml
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.3.0//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd">

<!--
$Id: validator-rules.xml 481833 2006-12-03 17:32:52Z niallp $

This file contains the default Struts Validator pluggable validator
definitions. It is contained in struts-core.jar, and should be
referenced in the struts-config.xml under the plug-in element
for the ValidatorPlugIn.

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

These are the default error messages associated with
each validator defined in this file. They should be
added to your projects ApplicationResources.properties
file or you can associate new ones by modifying the
pluggable validators msg attributes in this file.

# Struts Validator Error Messages
errors.required={0} is required.
errors.minlength={0} can not be less than {1} characters.
errors.maxlength={0} can not be greater than {1} characters.
errors.invalid={0} is invalid.

errors.byte={0} must be a byte.
errors.short={0} must be a short.
errors.integer={0} must be an integer.
errors.long={0} must be a long.
errors.float={0} must be a float.
errors.double={0} must be a double.

errors.date={0} is not a date.
errors.range={0} is not in the range {1} through {2}.
errors.creditcard={0} is an invalid credit card number.
errors.email={0} is an invalid e-mail address.

Note: Starting in Struts 1.2.0 the default javascript definitions have
been consolidated to commons-validator. The default can be overridden
by supplying a <javascript> element with a CDATA section, just as
in struts 1.1.

-->

<form-validation>

<global>

<validator name="required"
classname="org.apache.struts.validator.FieldChecks"
method="validateRequired"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
msg="errors.required"/>

<validator name="requiredif"
classname="org.apache.struts.validator.FieldChecks"
method="validateRequiredIf"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
msg="errors.required"/>

<validator name="validwhen"
msg="errors.required"
classname="org.apache.struts.validator.validwhen.ValidWhen"
method="validateValidWhen"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"/>


<validator name="minlength"
classname="org.apache.struts.validator.FieldChecks"
method="validateMinLength"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.minlength"
jsFunction="org.apache.commons.validator.javascript.validateMinLength"/>


<validator name="maxlength"
classname="org.apache.struts.validator.FieldChecks"
method="validateMaxLength"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.maxlength"
jsFunction="org.apache.commons.validator.javascript.validateMaxLength"/>


<validator name="mask"
classname="org.apache.struts.validator.FieldChecks"
method="validateMask"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.invalid"/>


<validator name="byte"
classname="org.apache.struts.validator.FieldChecks"
method="validateByte"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.byte"
jsFunctionName="ByteValidations"/>


<validator name="short"
classname="org.apache.struts.validator.FieldChecks"
method="validateShort"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.short"
jsFunctionName="ShortValidations"/>


<validator name="integer"
classname="org.apache.struts.validator.FieldChecks"
method="validateInteger"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.integer"
jsFunctionName="IntegerValidations"/>


<validator name="long"
classname="org.apache.struts.validator.FieldChecks"
method="validateLong"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.long"/>


<validator name="float"
classname="org.apache.struts.validator.FieldChecks"
method="validateFloat"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.float"
jsFunctionName="FloatValidations"/>

<validator name="double"
classname="org.apache.struts.validator.FieldChecks"
method="validateDouble"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.double"/>


<validator name="byteLocale"
classname="org.apache.struts.validator.FieldChecks"
method="validateByteLocale"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.byte"/>


<validator name="shortLocale"
classname="org.apache.struts.validator.FieldChecks"
method="validateShortLocale"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.short"/>


<validator name="integerLocale"
classname="org.apache.struts.validator.FieldChecks"
method="validateIntegerLocale"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.integer"/>


<validator name="longLocale"
classname="org.apache.struts.validator.FieldChecks"
method="validateLongLocale"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.long"/>


<validator name="floatLocale"
classname="org.apache.struts.validator.FieldChecks"
method="validateFloatLocale"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.float"/>

<validator name="doubleLocale"
classname="org.apache.struts.validator.FieldChecks"
method="validateDoubleLocale"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.double"/>


<validator name="date"
classname="org.apache.struts.validator.FieldChecks"
method="validateDate"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.date"
jsFunctionName="DateValidations"/>


<validator name="intRange"
classname="org.apache.struts.validator.FieldChecks"
method="validateIntRange"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends="integer"
msg="errors.range"/>

<validator name="longRange"
classname="org.apache.struts.validator.FieldChecks"
method="validateLongRange"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends="long"
msg="errors.range"/>


<validator name="floatRange"
classname="org.apache.struts.validator.FieldChecks"
method="validateFloatRange"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends="float"
msg="errors.range"/>

<validator name="doubleRange"
classname="org.apache.struts.validator.FieldChecks"
method="validateDoubleRange"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends="double"
msg="errors.range"/>


<validator name="creditCard"
classname="org.apache.struts.validator.FieldChecks"
method="validateCreditCard"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.creditcard"/>


<validator name="email"
classname="org.apache.struts.validator.FieldChecks"
method="validateEmail"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.email"/>

<validator name="url"
classname="org.apache.struts.validator.FieldChecks"
method="validateUrl"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.url"/>

<!--
This simply allows struts to include the validateUtilities into a page, it should
not be used as a validation rule.
-->
<validator name="includeJavaScriptUtilities"
classname=""
method=""
methodParams=""
depends=""
msg=""
jsFunction="org.apache.commons.validator.javascript.validateUtilities"/>

</global>

</form-validation>


Login.jsp
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<html:html> <head></head> <body>

<html:form action="/Login" method="POST">


<font color="red"><html:errors/></font> <br><br>


Username: <html:text property = "username" />
<br><br>

Gender:<html:radio property="sex" value="Male"/>Male<br>
            <html:radio property="sex" value="Female"/>Female<br>
<br>

Vehicle:<html:checkbox property="vehicle" value=" bike"/>I have a bike<br>
            <html:checkbox property="vehicle" value=" car"/>I have a car<br>
<br>

Location:<html:select property="location" >
<htmlption value="">Select</htmlption>
<htmlption value="Bangalore">Bangalore</htmlption>
<htmlption value="Chennai">Chennai</htmlption>
<htmlption value="Delhi">Delhi</htmlption>
<htmlption value="Mumbai">Mumbai</htmlption>

</html:select><br/>
<br>

What is your favourite color:<html:text property = "color" />

<br><br>

<html:submit value="Submit"/>
<html:reset value="Reset" />



</html:form>

</body>
</html:html>

Welcome.jsp
<html>
<head>
<title>Welcome</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%
String username=request.getParameter("username");
String color=request.getParameter("color");
String sex=request.getParameter("sex");
String vehicle=request.getParameter("vehicle");
String location=request.getParameter("location");
%>

</head>
<body>

Welcome <%= username %><br><br>
You are <%= sex %><br><br>
You have a <%= vehicle %><br><br>
Your location is <%= location %><br><br>
Your Favourite color is <%= color %>
</body>
</html>

ApplicationResource.properties
error.login.username.required=User Name is required.<br/>
error.login.username.length=User Name length should be between {0} and {1}.<br/>
error.login.username.invalid=User Name is invalid , it must be a-z, A-Z, 0-9, dash "-" or underscore "_".<br/>

error.login.color.required= Color is required.<br/>
error.login.sex.required= Please select your gender.<br/>
error.login.vehicle.required= Please select your vehicle.<br/>
error.login.location.required= Please select your location.<br/>


LoginAction.java
package com.testing;

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;

public class LoginAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward("success");
}
}


LoginActionForm.java
package com.testing;

import org.apache.struts.validator.ValidatorForm;

public class LoginActionForm extends ValidatorForm{

private String username ;
private String color ;
private String sex ;
private String vehicle ;
private String location ;
public String getUsername()
{

return username;

}
public void setUsername(String username)
{

this.username = username;

}

public String getColor()
{

return color;

}
public void setColor(String color)
{

this.color = color;

}
public String getSex()
{

return sex;

}
public void setSex(String sex)
{

this.sex = sex;

}
public String getVehicle()
{

return vehicle;

}
public void setVehicle(String vehicle)
{

this.vehicle = vehicle;

}

public String getLocation()
{

return location;

}
public void setLocation(String location)
{

this.location = location;

}

}
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you see your own posts? Are you aware you can edit them?
 
dhaval thakor
Ranch Hand
Posts: 53
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am really sorry for that david...I was new to forums.....

will keep in mind not to do again.
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic