File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes validate to check errors on jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validate to check errors on jsp" Watch "validate to check errors on jsp" New topic

validate to check errors on jsp

Liz Brown
Ranch Hand

Joined: Oct 22, 2002
Posts: 112
I am not initializing my page from jsp but from .do action.
I get a form.
I have a jsp-Action class-form defined in struts, and properties for I11N in file.

I want to check the prompt user with error when any of the fields are null or empty.

So I added validate() in my ~Form class. in struts i added the validate="true".
I added <html:errors bundle="MyResources"/> before form tag.
When i click submit(i.e. save operation), i am not coming back to the form. what may be the reason?

public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();

boolean mappingSetNameEntered=false;
System.out.println("in validate operation="+ _operation);
if(_operation=="save") {
if(mappingSetName ==null || mappingSetName.length()<1) {
errors.add("mappingSetName", new ActionError("error.mappingSetName.required"));
System.out.println("Inside validate:"+ mappingSetName);

return errors;

please help.
Liz Brown
Ranch Hand

Joined: Oct 22, 2002
Posts: 112
error.mappingSetName.required=mappingsetname cannot be null

is in my file
Mark Hartnett

Joined: Mar 01, 2005
Posts: 4
Put the following in your struts-config.xml action definition.

I agree. Here's the link:
subject: validate to check errors on jsp
It's not a secret anymore!