This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes struts validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "struts validation" Watch "struts validation" New topic

struts validation

leo oke

Joined: Jul 09, 2007
Posts: 21
I'm try to validate a form using struts Form with Validator, I want to validate the no input & maxlength. I've setup the configs but when I test the form it only shows "Validation Error(s), UserName is required."
even if I've put a username.. why?

part code:

form jsp

<html:javascript formName="loginForm"/>

<html:form action="/login">

<td width="15%">Enter your name:</td>
<td width="85%">
<html:text property="name" size="25" maxlength="50"

public class LoginForm extends org.apache.struts.validator.ValidatorForm{

private String name = null;

private String result ;

public void setName(String name) { = name;

public String getName() {
return name;

public void setResult(String result) {
this.result = result;

public String getResult() {
return result;

<form name="loginForm">

<arg position="0" key="loginForm.username"/>
<arg position="1" key="${var:maxlength}" name="maxlength"


I agree. Here's the link:
subject: struts validation
It's not a secret anymore!