3 Replies Latest reply on Jan 20, 2006 7:37 AM by jlaskowski

    want to send data from portlet

    davinchi

      How can I send data catched from a portlet,
      Suppose I have a jsp, on submitting the request I want to send the data on the page to another portlet.
      I know that I can process using processAction and render methods but I dont know how I can call them from a jsp.

        • 1. Re: want to send data from portlet
          jlaskowski

          Hi,

          Use RequestDispatcher (RD) and request.setAttribute().

          public void doView (RenderRequest request, RenderResponse response)
           throws PortletException, IOException
          {
           response.setContentType("text/html");
           request.setAttribute("myAttr", "myValue");
           PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("another.jsp");
           rd.include(request,response);
          }


          The point is to set up the content type of a response (very likely it's text/html) *and* use RD.include() as forward() is not allowed.

          BTW, You may find this and other answers in a very valuable book - http://www.manning.com/books/hepper. It's distributed at no charge (!)

          --
          Jacek Laskowski
          http://www.laskowski.org.pl

          • 2. Re: want to send data from portlet
            davinchi

            thanks jacek,

            But additionally if I on click of submit suppose I want to invoke a portlet.
            I tried using the following command

            PortletURL cancelUrl = aResponse.createRenderURL();
            cancelUrl.setPortletMode(PortletMode.VIEW);

            but these methods are not present in my jar.(I think they are specific to pluto)

            How can I do the same in JBoss Portal



            • 3. Re: want to send data from portlet
              jlaskowski

              Hi,

              You didn't read the book, did you? ;) Neither did I yet, but I'm pretty sure there's the answer. Anyway...

              As you might've tried, you can include a jsp page into a portlet. So can you include a servlet, since a jsp is a servlet at runtime. Create a servlet-mapping (if it's not done for you automatically, e.g. /servlet/YourServlet) and include it into PortletRD as you did with the jsp.

              --
              Jacek Laskowski
              http://www.laskowski.org.pl