From processAction(), redirect to JSP within Portlet - Websphere

This is a discussion on From processAction(), redirect to JSP within Portlet - Websphere ; This is pretty simple within the doView() method: {code} public void doView(RenderRequest request, RenderResponse response){ ... PortletRequestDispatcher portletrequestdispatcher = null; portletrequestdispatcher = getPortletContext().getRequestDispatcher("/jsp/login.jsp"); ... portletrequestdispatcher.include(request, response); ... } {code} The above doView() code works fine. I want to do the ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: From processAction(), redirect to JSP within Portlet

  1. From processAction(), redirect to JSP within Portlet

    This is pretty simple within the doView() method:

    {code}
    public void doView(RenderRequest request, RenderResponse response){
    ...
    PortletRequestDispatcher portletrequestdispatcher = null;
    portletrequestdispatcher = getPortletContext().getRequestDispatcher("/jsp/login.jsp");
    ...
    portletrequestdispatcher.include(request, response);
    ...
    }
    {code}

    The above doView() code works fine.

    I want to do the exact same thing but from within my processAction(). Obviously the PortletRequestDispatcher will not allow me to do this b/c in the processAction I have ActionRequest & ActionResponse (the .include() method takes RenderRequest and RenderResponse).

    I have now tried to do a redirect:

    {code}
    public void processAction(ActionRequest request, ActionResponse response) {
    ...
    response.sendRedirect("/jsp/someTestPage.jsp");
    ...
    }
    {code}

    The above sendRedirect code does not work within the processAction. I always get a 404 not found error.

    Is there any way that I can access the PortletRequestDispatcher from within the processAction or do something similar in order to access a different JSP page that resides within my portlet?

    Thanks,
    Sean

  2. Re: From processAction(), redirect to JSP within Portlet

    Well a few questions, Do you want the JSP to be viewed within the context of the portlet or redirect to just that jsp so that the jsp is the only thing rendered?

    You could build the url and redirect to that. But the problem is you are not building the url correctly as sendredirect points to a url not a filepath location.

    So if you want to display the jsp in the context of the portlet send a param to the doview, and just have it display that jsp instead



    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

  3. Re: From processAction(), redirect to JSP within Portlet

    That is exactly how I ended up solving the problem, I just did not update this thread.

    Thanks for the response.

    - Sean

+ Reply to Thread