• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

<html:error> tag doubt in struts 1

 
carox kaur
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am referring the book :professional Jakarta Struts 1.1, wrox publication. Chapter 10 'Managing errors' describes the process of Error handling in struts application. In Listing 10.2 index.jsp, there are two input controls : name and password, both are textfields. Just after these textfileds <html:error> tag is embeded to catch the errors. The code given in the book is:

what i know is when we write the <html:error> tag we have to mention the 'property' attribute also:
<html:error property="symbol1"/>.-------------------------(3)

The reason this is required is when we make the ActionErrors object, we code like this:
ActionErrors err=new ActionErrors();
err.add("symbol1,new ActionError("keyname"));-----------(4)

So the "symbol1" in the above add method is the value specified in the property at (3). So if we won't specify the property attribute then how will the <html:error> will know about the error it refers to. Which error it will pick from the collection represented by ActionErrors object?

Secondly,In the book at page 169 below listing 10.3 its written that the "symbol1" at 4 is the value of the property of the <html:text> tag at (2).
But I have read that this "symbol1" at (4) corresponds to the value of the property of <html:error > tag at (3). I dont know which is correct. Please help me in understanding the true concept.

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, that's an old version of Struts.

<html:errors/> displays *all* the action errors. With a "property" attribute it displays the errors for that property. Just like it says in the documentation.

http://struts.apache.org/1.1/userGuide/struts-html.html#errors

(And as far as I know there is no <html:error> tag--when asking questions it's important to be as precise as possible :)
 
carox kaur
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.....sure I ll take care next time....


Secondly,In the book at page 169 below listing 10.3 its written that the "symbol1" at 4 is the value of the property of the <html:text> tag at (2).
But I have read that this "symbol1" at (4) corresponds to the value of the property of <html:error > tag at (3). I dont know which is correct. Please help me in understanding the true concept.

So that also means that 'symbol1' corresponds to the value of the property of <html:text> tag, according to struts 1.1.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
carox kaur wrote:But I have read that this "symbol1" at (4) corresponds to the value of the property of <html:error > tag at (3). I dont know which is correct. Please help me in understanding the true concept.

<html:errors> look for the property in the action errors/measages. Consider this "property" as a key when it comes to find out the respective error message. Like, if you want to display invalid login info error message, you will do something like this:


And upgrade to the latest Struts version.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic