Error Messages in Jsps

Standard Error Messages

To make life easier for our users and our translators, please use this set of standard error messages. The entries below are formatted so that they can be copied straight into your ApplicationResources.properties file. Please do not remove the "#" comments as these will be shown in the translation utility.

User Error Messages

These are error messages that warn the user of something within their (or another users) control.

System Error Messages

To reduce the work (and confusion) for our translators, keep any system error messages to a minimum. For example, rather than than having "ToolContentID is missing", use "An error has occurred. Please start again. Parameter {0} is missing." and use ToolContentID as the replacement value.

If an exception occurs then you can use "An error has occurred. Please start again. Reason for error: {0} " and replace {0} with the exception text. If this occurs then the user may see the message in a mixture of languages. For example, if they are using Bulgarian they will see the "An error has occurred. Please start again. Reason for error: " in Bulgarian and the exception message in English.

The idea is to give the user enough information so that they know a system error has occurred, and there should be enough information on the screen so that if they do a screen dump and send it back to the developer, the developer will have some idea about the problem. The user doesn't need to understand the full message - most of our users won't have a clue what a ToolContentID is irrespective of the language!

ActionMessages Tips

Every now and then the JSPs need to present the user with messages like: "An error has occurred. Please start again. Parameter ToolContentID is missing.", where the messages are generated programmatically. Given below are some suggestions on how to do this.

The suggestions here apply ONLY to server (Struts Action) originated messages as opposed to form validation messages. So, the suggestions here does not apply to individual field level corrections. Individual field level corrections usually takes the user of the system to a particular field to fix an error. Now, this section is about raising and presenting all general user messages, feedback and optionally warnings for field level corrections.

The usual practice is to present a server originated messages (not necessarily error messages only) at the top section of the related screen.

For the purpose of displaying Struts 1.2.7 Action Messages in the JSP pages we can follow the following practice:

Assume that an input parameter "toolContentID" is mandatory.

We could have some verification code in the related Action class as:

To display the error:

  • The "error.missingParam" must be included in to your ApplicationResources.properties file.
  • In the standard stylesheet, there should already be an "error" style.
  • Create an errorbox.jsp based on Action Messages (rather than Action Errors of the previous Struts versions). A simple one can be like:
  • In your JSP page include the error box.
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.