Hi,

I'm getting into trouble porting a webapp to jahia using a MVC architecture
(but no framework like Struts...).

The concept is simple, using complementary path:

1. A form post to a servlet with a path and a complementary path:
-----------------------------------------------------------------------
(...)
<form name="formulaire" method="post"
action="<%=response.encodeURL(request.getContextPath() +
"/ElmtCtrl/EventPreview")%>" onSubmit="return verifierFormulaire();">
(...)

The path to the servlet controler is "ElmtCtrl" and the complementary path
(next view) is /eventPreview    

2. The servlet controler analyse the complementary path, then create the 
model as a bean, then forward to the next view:     
-----------------------------------------------------------------------
(...)
protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1)
throws ServletException, IOException {

        RequestDispatcher dispatcher=null;
        ServletContext context = getServletContext();
                
        try{
                // get the name of the view analysing the complementary path
                String name = arg0.getPathInfo();
                name = name.substring(1);
                (...)
                        
                // Create model as a javabean
                if ("NewsPreview".equals(name)){
                        NewsModel news = (NewsModel)session.getAttribute("news");
                        (...)
                }  
                else if ("EventPreview".equals(name)){
                        EventModel event = (EventModel)session.getAttribute("event");
                        (...)
                } 
                else throw (new Exception());
                        
                // Forward to the next view...
                dispatcher = context.getNamedDispatcher(name);
                if (dispatcher == null) throw (new Exception());
                        
        } catch(Exception e){
                log("Exception in ElmtCtrl.doPost()");
                dispatcher = context.getNamedDispatcher("ErrorView");
        } finally {
                // Forward is here...
                dispatcher.forward(arg0, arg1);
        }       
}     
(...)

This works fine into TOMCAT but into a jahia portlet I got the error
message:

 "Error while retrieving application j2EE news and events for RPN"    

I'm wondering if I need to write:

dispatcher = context.getNamedDispatcher(arg1.encodeURL(name));

or something like that because Web application Developer Guide show page 24
it's the good maner to do with HTTP Redirects from web applications...

Any help is very welcome!

Thanks.
--
-- 
Patrick Gelin - Collaborateur Scientifique
Office de la Statistique et de l'Informatique Scolaires (OSIS)
CH-2300 La Chaux-de-Fonds
Tél.: +41 (0)32 919 79 13
Email: [EMAIL PROTECTED]

Reply via email to