You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-user@portals.apache.org by janwacker <hn...@yahoo.com> on 2007/10/18 13:45:59 UTC

Problem porting Servlet to Portlet Webapplication

Hello everybody !

I`m currently trying to port a Springframework-based Servlet Webapplication
to a Portlet one. Everything so far worked fine, but now I`m facing a major
problem which I`m currently unable to solve. To give you an impression of my
work so far:

Software used 

Tomcat 5.0.28
Pluto 1.0.1
Spring 2.0.6

General Strategy

To reuse a lot of the existing servlet-infrastructure, I`ve decided to
modify the 
Spring-class DispatcherPortlet so that it is able to dispatch the
request/response to my (Servlet)handlers, turn the resulting servlet-MaV
into a portlet MaV, which is then passed on to be rendered. 

Strategy Details

- turn a servlet MaV into a portlet MaV

this is the code used to perform the change:

        Object myView =servletMaV.getView();
        if (myView != null){
            portletMaV.setView(myView);
        }else {
            portletMaV.setViewName(servletMaV.getViewName()); 
        }
        portletMaV = portletMaV.addAllObjects(servletMaV.getModelMap());
		
redirect view

Since these are frequently used in the servlet application yet afaik
unimplementable in a portlet context, my solution has been to catch them and
simply running the request handling method of the DispatcherPortlet again.
With the new "url" provided by the redirect view of course. 


The problem

Everything works fine, up to the following point: I´ve got a link in the
portlet using a render url. I click on it, the server generates a request
and passes it on to my DispatcherPortlet. The DispatcherPortlet determines
the handler to be used and processes it. The first handler comes up with a
redirect view, this is processed and a new handler is found, which returns
the MaV to be rendered. During the resulting rendering process something
strange happens.
An object of the ApplicationFilterChain class (tomcat stuff) calls the
service-method of its current servlet. That happens to be an object of the
PortletServlet class. As parameters the PortletServlet object receives a
RenderRequestImpl object and a ServletResponseWrapperInclude object.
During the processing of the PortletServlet object`s service method, the
renderRequest is changed so that it points to itself ( by the PortletServlet
method prepareRenderRequest, which does a lateInit call on the request). The
shortly thereafter following getLocaleContext call on the request then leads
to the request continuously asking itself, eventually resulting in a stack
overflow.

I hope someone can explain to me why this happens and how to fix it, any
help is very much appreciated.

Thanks,

Jan
-- 
View this message in context: http://www.nabble.com/Problem-porting-Servlet-to-Portlet-Webapplication-tf4646237.html#a13272188
Sent from the Pluto - User mailing list archive at Nabble.com.