Check out my kickstarter CLICK HERE
My book, my movies, my videos, my podcasts, my events ... the big collection of paul wheaton stuff!
Originally posted by Bear Bibeault:
If the "action" servlet is idempotent (causes no state change), then the middle redirect is not necessary to "break" the request. In such cases, it's ok to forward from the "action" servlet to the "view prep" servlet.
Originally posted by Bear Bibeault:
You may still want to redirect though in order to "convert" a POST to a GET. In any case, I always still segregate the "action" code from the "view prep" code.
A good workman is known by his tools.
Originally posted by Marc Peabody:
On idempotent requests, you don't need an "action" servlet. You can point it straight to the "view prep" servlet.
Originally posted by Marc Peabody:
But you shouldn't use POST on idempotent requests anyway, unless perhaps you're submitting DNA mappings for a medical app or something else with ridiculously huge parameter values that won't fit in a GET.
Originally posted by Bear Bibeault:
Not always. There are many categories of actions that cause no state change. Firing off e-mail messages is one off the top of my head. It has nothing to do with "view prep" and should be it's own unit. I see no reason to bundle action code into view prep code in such a case.
Originally posted by Bear Bibeault:
It doesn't take much data to go beyond the limits of a GET. Mail message bodies, to use the same example as above. I usually use POST on form submissions to "action" servlets regardless of whether that action is going to cause a state change or not. It might violate the sensibilities of "HTTP purists", but within the realm of the web app it has its own satisfying consistency. (And keeps submitted data off the URL, which I like).
A good workman is known by his tools.
Originally posted by Marc Peabody:
But doesn't sending an email change the state of someone's email Inbox?
Originally posted by Marc Peabody:
In the absence of a redirect, clicking Refresh multiple times would cause the "unit of work" to repeat and flood someone's Inbox!
Originally posted by Marc Peabody:
What about search functionality? Using POST for that would prevent browser bookmarking
Originally posted by Marc Peabody:
and cause strange effects when selecting Refresh
Originally posted by Marc Peabody:
I hope you're finding this discussion fun and interesting rather than annoying, by the way.
Originally posted by Bear Bibeault:
True, but I wouldn't consider that part of the application's model.
A good workman is known by his tools.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |