11 Replies Latest reply on Oct 26, 2006 1:12 PM by Peter Johnson

    How to show my JSP page in a portlet.

    Srejith P K Newbie

      Hi,

      How to show my JSP page in a portlet.
      I have used IFrame portlet instance for the same but still I feel it pretty complex. I just want to create few portlets which should show different web sites. I have used plumtree there we can add a portlet by specifying a particular URL. is there any solution to create a portlet like that, without creating my own war file?

      I would appreciate any response.

      Thanks,
      Sreejith

        • 1. Re: How to show my JSP page in a portlet.
          Thomas Heute Master

          Have a look at http://www.portletbridge.org/

          Also note that it is probably illegal to include copyrighted content from rediffmail in your own portal if you plan to share it. I would ask for their consentment first.

          • 2. Re: How to show my JSP page in a portlet.
            mmontoni Newbie

            Hi,

            you need a .jsp page that you want to display and whithin your portlet in your .java class you can do the following:

            protected void doView(RenderRequest rRequest, RenderResponse rResponse) throws PortletException, IOException, UnavailableException
             {
             rResponse.setContentType("text/html");
            
             String sPage = (String) rRequest.getParameter("page");
            
             if(sPage != null)
             {
             PortletRequestDispatcher prd = getPortletContext ().getRequestDispatcher("/WEB-INF/jsp/construction.jsp");
             prd.include(rRequest, rResponse);
             }
             else
             {
             PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/view.jsp");
             prd.include(rRequest, rResponse);
             }
            
             }
            


            I hope it helps...

            --Mariella.

            • 3. Re: How to show my JSP page in a portlet.
              Srejith P K Newbie

              Hi Mariella,

              Thanks for your immediate response.
              Let me try to expose my requirement.
              I am working for an MNC and they have different web application (j2ee) running in different servers. I just want to show these different applications (probably index.jsp) as different portlet in the Portel. Please note I just have the URL of these applications. I have tried to use IFrame portlet for the same, but that doesn?t meet the requirement. now can you please suggest how can I do the same using JBoss portal server.

              * I would appreciate any response.

              Thanks once again,
              Sreejith-

              • 4. Re: How to show my JSP page in a portlet.
                mmontoni Newbie

                Hi,

                I would suggest IFrames. Why it doesn't meet the requirements? In the portlet swap I used the portlet IFrames Jboss offers to open an app I have inside of a portlet (I only had the URL as well). It worked very well...

                You could try using web services too, but that would only bring you the app data not the URL, and this is all you have right?

                --Mariella.

                • 5. Re: How to show my JSP page in a portlet.
                  Srejith P K Newbie

                  Hi,

                  I tried using iFrame portlet.

                  I login as an admin, and created a page with an iframe portlet.
                  I have edit the URL using edit option and updated.
                  Fine, its working fine. Its showing the updated url content in the portlet. BUT,
                  when I login as another user it is displaying the default content itself.(the jboss url).

                  I just want the admin changed url should be view by all other users.

                  anybody can help me out.

                  Thanks
                  Sreejith-

                  • 6. Re: How to show my JSP page in a portlet.
                    mmontoni Newbie

                    Hi,

                    when I did the iFrame, I download the portlet and hot deploy it JBoss AS. I haven't done through the ADMIN. In the portlet.xml of your iFrame you can configure to what type of users can see it.

                    Also, I suspect that there is a way to give user privileges to a portlet through the ADMIN. Please, investigate int he documentation of JBoss portal. I think I saw something like that there...

                    --Mariella.

                    • 7. Re: How to show my JSP page in a portlet.
                      Peter Johnson Master

                      I thought that the IFrame Portlet would use preferences to set the URL to display, but it doesn't. So it looks like theo nly way to do what you wnat (change it once for all users), you will first have to modify the portlet source to use preferences to read the URL. Once you do that, you can set the URL globally for all users on the Instances view in the Manegement Portlet.

                      If I have a few minutes available in the next couple of days I could make this change (I'm swamped today).

                      • 8. Re: How to show my JSP page in a portlet.
                        Srejith P K Newbie

                        Hi

                        According to Peter's reply, I have to modify the source of the portlet to display the app url in the portlet. OK,
                        If I have more than one application, what should I do? Should I deploy as much as iFrame portlet instacne and modify each instance for each URL?

                        Even though its working I feel that its a bit a round about way of achieving our purpose. Will there any direct way of doing the same?

                        * Where do I find (path) the source of the portlet once deploy a war in the portal?

                        Thanks for your updates,
                        Sreejith-

                        • 9. Re: How to show my JSP page in a portlet.
                          Jérôme de Chastonay Newbie

                           

                          "mmontoni" wrote:
                          Hi,

                          you need a .jsp page that you want to display and whithin your portlet in your .java class you can do the following:
                          protected void doView(RenderRequest rRequest, RenderResponse rResponse) throws PortletException, IOException, UnavailableException
                           {
                           rResponse.setContentType("text/html");
                          
                           String sPage = (String) rRequest.getParameter("page");
                          
                           if(sPage != null)
                           {
                           PortletRequestDispatcher prd = getPortletContext ().getRequestDispatcher("/WEB-INF/jsp/construction.jsp");
                           prd.include(rRequest, rResponse);
                           }
                           else
                           {
                           PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/view.jsp");
                           prd.include(rRequest, rResponse);
                           }
                          
                           }
                          


                          I hope it helps...

                          --Mariella.




                          Hello,

                          I saw your example but I have a question.

                          How to make to integrate internationalization in this Portlet? Can you give me an example of internationalized Portlet?

                          Thank you




                          • 10. Re: How to show my JSP page in a portlet.
                            Peter Johnson Master

                             

                            "sreejipnr" wrote:
                            If I have more than one application, what should I do? Should I deploy as much as iFrame portlet instacne and modify each instance for each URL?


                            Yes, if you hard code the URL in the source, you will have to create multiple portlets (e.g. IFram1, IFrame2, IFrame3, etc.). However, what I planned on doing is not hard-coding the URL but getting it from the preferences. This is a very simple change. Then I could create multiple instances and set the URL differently for each one.

                            Looks like I might have a few minutes today. I'll let you know when I am done and it's working.

                            • 11. Re: How to show my JSP page in a portlet.
                              Peter Johnson Master

                              I was wrong. The IFRame portlet already supports preferences. Thus you can create multiple instances of the IFrame portlet, either using a portlet-instances.xml file of using the Managent Porltet, and setting the preferences for each instance. The preferences are:

                              * iframeurl
                              * iframewidth
                              * iframeheight
                              * iframemessage (the text to display if the browser does not support iframes)