You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Alexander Klimetschek <ak...@adobe.com> on 2011/03/07 13:00:20 UTC

Re: [day-communique] Re: Chanding HTTP verb from POST to GET while handling request

On 07.03.11 08:08, "Unmesh Joshi" <un...@gmail.com> wrote:
>I was looking at code of
>com.day.cq.wcm.foundation.forms.impl.FormsHandlingServlet.
>It is actually changing http verb from POST to GET by wrapping http
>request. Is this an exception or is this an idiom followed in CQ/Sling
>development?

Depends on the use case. In case of the forms handling servlet, it does a
lot of internal includes on the form action JSPs, which should not be
POSTs but simply run the desired "<selector>.jsp" (e.g. init.jsp,
forward.jsp, servervalidation.jsp), but still keep the request with all
the parameters available.

>I see POST-REDIRECT-GET as a cleaner and Restful way of handling such
>kind of situation.

HTTP-level redirect is no option in the above case, where multiple
includes are done per request, and these should directly address
fixed-named JSPs.

>Changing HTTP verb does not seem very Restful.

REST is about the general architecture and the (general constraints for
the) protocol between client and server. It does not mandate any
implementation. As long as the REST/HTTP semantics are kept up, it is
irrelevant in which JSP or method the logic is implemented. Sling's
script/servlet resolution is just there to make it easy for most cases,
but sometimes it is necessary to tweak it.

Regards,
Alex

-- 
Alexander Klimetschek
Developer // Adobe (Day) // Berlin - Basel