Hi I have a struts 1.X app, and in order to show errors detected in an action class, I use:
errors.add("Error Global", new ActionMessage("some_string_in_properties_file"));
Which works just fine.
My problem is that now the string I need to send to the jsp page as error has a session variable in it (like “You have 3 more valid attempts”, being 3 the session variable).
How can I accomplish this ?
Thanks.
Try to use ActionMessage constructor of 2 arguments. According to JavaDoc:
public ActionMessage(java.lang.String key, java.lang.Object value0) Construct an action message with the specified replacement values. Parameters: key - Message key for this message value0 - First replacement valueIn your case:
errors.add("Error Global", new ActionMessage("some_string_in_properties_file", sessionVariable));some_string_in_properties_fileshould look like this:some_string_in_properties_file=You have {0} more valid attempt(s)