0

I have a function say :

 public void display(ActionRequest areq, ActionResponse ares) throws Exception,PortletException,IOException {

 String name= areq.getParameter("name");
 String add= areq.getParameter("add");
 String phone= areq.getParameter("phone");
}

I have a jsp say disp.jsp which passes the user input to the above function display. Now I after doing some processing on the above data in display() function, I want to display the results on a jsp page say new.jsp. How should I go ahead with it? I tried something like:

areq.setAttribute("name",name);
areq.getRequestDispatcher("new.jsp").forward(areq, aresp); but it shows an error that getRequestDispatcher is not defined for actionrequest and actionresponse.

I am using liferay framework

Seeya K
  • 1,221
  • 6
  • 27
  • 43

1 Answers1

2

In your action you can set attributes and set the redirect page like that:

public void display(ActionRequest aReq, ActionResponse aResp){


    aReq.setAttribute("name",name);

    aResp.setRenderParameter("jspPage", "/new.jsp");
}

I Usually prefer setting attributes instead of Parameters, because it allows to pass non Sting variables. Then, in the jsp you can get the attributes

<%
String name = (String)renderRequest.getAttribute("name");   
%>

Just remember to include this, to have access to renderRequest object

<portlet:defineObjects />
yannicuLar
  • 3,083
  • 3
  • 32
  • 50