Hi Matthias,

Matthias Wermund schrieb:
> after just reading for some week it's now time for my first own question.

So, welcome then ;-)

To recapitulate: Your requests are generally POST requests due to the
legacy nature of the application. But once entering the system, the
requests should not be handled by the SlingPostServlet but by the
regular "GET" servlets and scripts used for reguaölr GET requests. Right ?

In this case, my solution would be to have a very simple top-level page
handling servlet. This servlet would do the following in its doPost method:

   SlingHttpServletRequest req =
       new SlingHttpServletRequestWrapper(originalRequest) {
           public String getMethod() {
               return "GET";
          }
       };

   RequestDispatcher rd = req.getRequestDispatcher(req.getResource());
   rd.forward(req, originalResponse);

This should probably do the trick.

HTH

Regards
Felix


> 
> 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: [email protected] 
> 

Reply via email to