dev@jsr311.java.net

RE: Container Independence

From: Jerome Louvel <jerome.louvel_at_noelios.com>
Date: Wed, 11 Apr 2007 10:25:11 +0200

> Paul and I thought about that but in the end we decided against it
> for the reason that a redirection and many other 2XX and 3XX codes
> aren't really exceptional but rather business as usual so
> they should
> be treated as exceptions which are associated with errors. Also
> catching exceptions is relatively expensive.

From a POJO point of view, it does makes sense to rely on exceptions for all
client and server error statuses.

However, for all success and redirection statuses, the mapping to the
exception concept is not as clean.

I suggest that we explore an intermediary path where 4xx and 5xx codes can
be expressed as exceptions. Redirections could be expressed using another
mechanism such as:

        public class Context {
                // Success methods
                void successOk();
                void successCreated();

                // Redirection methods
                void redirectPermanent(uri);
                void redirectSeeOther(uri);
                void redirectTemporary(uri);

                // Direct status manipulation
                int getStatus();
                String getReasonPhrase();
                void setStatus(int code);
                void setReasonPhrase(String reasonPhrase);
        }

Best regards,
Jerome