Hi, a quick answer:
1) to handle POSTs, you must extend SlingAllMethodsServlet, since POST is not a safe method ;-) 2) you say you don't want to subclass / write a POST.java for each component, but they should have a specific behaviour, ie. at least "override" the default sling post servlet behaviour and do nothing; well, in this case you have to provide a specific POST handler for each of your components 3) if they all behave the same way, ie. an empty POST handler that should only be overridden by certain components, introduce a super resource type "component", eg. /apps/generic/component and put the (empty) POST.java in their and set sling:superResourceType on the components. Regards, Alex On Mon, Aug 17, 2009 at 1:22 PM, Matthias Wermund<matthias.werm...@namics.com> wrote: > Hello to everyone, > > after just reading for some week it's now time for my first own question. > > I want to integrate a legacy application in a website based on Sling (in > Day CQ5). > This legacy application renders itself using Portlets, so it enforces the > use of POST forms if the user submits any data. The application is > embedded using RequestDispatcher.include(req,res). > > Now we all know about the magic SlingPostServlet, but in this case I > obviously don't want to use it. In case of a POST, I want just to display > the page as usual and pass the request to the embedded application. > The page is based on components, which are included using > RequestDispatcher.include(req,res). The page and all components inherit > from SlingSafeMethodsServlet. They are not registered using @scr > annotations, but evaluated directly inside the content tree. > > To catch the POST before the SlingPostServlet, I can use a subclass of the > page, so the structure would look like this: > > /apps/all/pages/mypage.java > /apps/all/pages/POST.java > > I tried this already and it works. > > But: > As I said above, the page includes components using > RequestDispatcher.include(req,res). These components don't have the > POST.java. Because the SlingHttpServletRequest is still of method POST, > the SlingPostServlet catches these includes and none of them actually > resolve to the component's servlet. > > To differ between wanted SlingPostServlet requests and the legacy-POSTs I > use a selector in the legacy-POSTs. But the main problem remains: As soon > as I dispatch the request beyond the page, I will be caught by > SlingPostServlet. It would be ideally to have something like > SlingRequestDispatcher.includeIgnoreMethod(req,res) or so ;-) > > Some things I quickly tried but didn't lead to solutions were: > - Extending SlingAllMethodsServlet instead of SlingSafeMethodsServlet in > the page > - Using SlingHttpServletRequestWrapper with overrided getMethod() to > return always GET > > How can I solve this? Subclassing all of my components with a POST.java > too is not really an option... > > > Thanks in advance. > > Regards, > > Matthias Wermund > Software Engineer > --------------------------------------------------------------------- > namics ag - ein Unternehmen der PubliGroupe > Teufenerstrasse 19 > CH-9000 St. Gallen > http://www.namics.com > http://blog.namics.com > mailto: matthias.werm...@namics.com > -- Alexander Klimetschek alexander.klimetsc...@day.com