Hi, 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?
I see POST-REDIRECT-GET as a cleaner and Restful way of handling such kind of situation. Changing HTTP verb does not seem very Restful. Thanks, Unmesh On Sat, Mar 5, 2011 at 9:29 PM, Justin Edelson <[email protected]> wrote: > Why not just register your scripts to handle POST requests? > > On 3/5/11 8:17 AM, Unmesh Joshi wrote: >> Hi, >> >> As I have discussed in earlier threads, our current project is >> migration from Spring-MVC based application backed by Teamsite to Day >> CQ. Its planned to migrated thin slices of the application from >> Spring-MVC to CQ/Sling. >> One of the proposed approaches is to migrate just the View JSPs in CQ. >> This means migrate just the JSPs and create CQ components (which will >> be based on same JSPs). >> No changes will be done in existing Spring controllers. CQ will be >> used just for rendering pages. An interceptor is written which >> forwards request to CQ/Sling instead of JSPs. >> >> So the flow looks as following. >> >> Existing spring MVC >> >> HTTP POST ----> Spring MVC Controller ---> Request forward (Using >> request dispatcher forward) ---> JSP page. >> >> With CQ co existing with Spring MVC >> >> HTTP POST ---> Spring MVC Controller ---> Spring Interceptor ---> >> Request forward (Using ServletContext.dispatcher.forward) ---> >> CQ/Sling Page URL >> >> The problem with the interceptor is that while it can forward requests >> to CQ/Sling (Just as you forward request to other web app in same >> container), the HTTP request still remains as POST. CQ/Sling (because >> its based on Restful model) have very different meaning for POST and >> GET. >> >> So, an proof of concept was done, where before forwarding a request to >> CQ, its wrapped in custom RequestWrapper which overrides getMethod >> method and returns 'GET'. >> e.g. >> CustomerRequestWrapper extends HttpServletRequestWrapper { >> >> public String getMethod() { >> return "GET"; >> } >> >> } >> >> This seems to be working. >> >> But I want to know if this kind of verb changing in the same request >> can run into any issues? >> >> Thanks, >> Unmesh > >
