This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Struts and the fly likes how to use html:errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to use html:errors" Watch "how to use html:errors" New topic

how to use html:errors


Joined: Sep 14, 2005
Posts: 2
I am new in Struts. I want to display error message in view. For that, in my bean (ActionForm) I have written validate() method :-

ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
ActionErrors errors = null;
if( name.equals("") )
errors = new ActionErrors();
errors.add("error_username", new ActionError(""));
return errors;

In view I have wriitten "html:errors".
But it is not displaying me anything what else I have to do to show error messages.Can u tell me.

A Harry
Ranch Hand

Joined: Jan 23, 2002
Posts: 124
you will need to have something along the lines of -

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

at the top of you page otherwise the "html" tag will be meaningless!

Joined: Sep 14, 2005
Posts: 2
hi A Harry,
That I have alredy included. Something else that I have to do. Do I have to mention something in struts-config.xml file.

vijaya bharath
Ranch Hand

Joined: Jun 10, 2005
Posts: 66

Ya u need to specify in struts-config.xml as validate=true while declaring action tag. And be sure that is in And place that properties file under WEB-INF\classes. Check it works.
[ September 14, 2005: Message edited by: vijaya bharath ]

Regards,<br />Vijaya Bharath.<br />SCJP1.4 <br />SCWCD5.0
I agree. Here's the link:
subject: how to use html:errors
It's not a secret anymore!