struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "sarat.pediredla" <>
Subject Re: Struts, Interceptor error message customization
Date Sat, 16 Feb 2008 13:49:14 GMT

I think the message customisation has been covered so onto trapping
interceptor results.

The easiest way you can trap a 500 error is to define the following XML in
your web.xml file,


In your error page, you will have access to the actionErrors collection
which will be populated by the FileUploadInterceptor.

Laurie Harper wrote:
> Mike J. M. wrote:
>> Hello,
>> So I am currently using Struts, including an action that has a fileUpload
>> Interceptor that checks for files that are too large and certain
>> allowable
>> file types. Right now if either of these conditions are met, the system
>> will
>> throw a generic HTTP 500 error up. What I am wondering is how to
>> customize
>> this.
>> in the docs:
>> i found these messages that i can supposedly customize. however, the doc
>> does not specify WHERE i am supposed to put these error messages at, and
>> furthermore, after looking at the source code for FileUploadInterceptor,
>> I
>> found that these messages are printed to the log file, and it doesn't
>> look
>> like it prints to the actual HTML.
>> * struts.messages.error.uploading - a general error that occurs when the
>> file could not be uploaded
>> * struts.messages.error.file.too.large - occurs when the uploaded file is
>> too large
>> * struts.messages.error.content.type.not.allowed - occurs when the
>> uploaded
>> file does not match the expected content types specified
>> The doc says that these error messages originate from
>> I'm guessing that's in the struts.jar itself
>> because I don't see it anywhere else, so am I supposed to modify that
>> directly? I'm a little bit iffy about doing that.
> It's not obvious from the documentation, but the message come from the 
> 'global message resources', which you configure via the 
> struts.custom.i18n.resources property in The 
> file mentioned is where the standard defaults 
> are stored.
> So, create a resource bundle containing your customized error messages, 
> say, and place it in the classpath, then 
> add a 
> property to your configuration.
>> So, in a nutshell, how do I catch an Interceptor error and make it
>> redirect
>> to a nice page instead of the generic HTTP 500 page? Actually, what would
>> be
>> better is to redirect to an action while passing into it a parameter
>> "message" that will contain error messages. Then, in the JSP i want to do
>> <s:property ...> to grab that message.
> I'm not sure about this part. I would expect, assuming you implement 
> ValidationAware (e.g. by extending from ActionSupport), that you would 
> get a validation failure rather than a status 500 response. If you're 
> still experiencing that, post the corresponding error logs and stack
> trace.
> L.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message