You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Enrique Perez <pe...@dit.upm.es> on 2007/03/28 18:53:34 UTC

JSP advice

Hi,

I'm not used to JSP and I'm getting some trouble to make a portlet 
redirect the request to a JSP.

I've started with a very simple JSP:
---   view_01.jsp   -------------------------------------
<%@ page contentType="text/html" %>
<%@ page pageEncoding="UTF-8" %>
<%@ page import="javax.portlet.*" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>

<portlet:defineObjects />

<form action="" method="post">
    <table>
        <!-- Row 1: is reserved for info -->
        <tr>
            <td colspan="3">Please, fill in the gaps with the appropiate 
info...</td>
        </tr>
        <!-- Row 2: displays error messages -->
        <% int flag = 1; %>
        <% if (flag==1){ %>
        <tr>
            <td colspan="3">Show error message</td>
        </tr>
        <% } %>
        <!-- Row 3+: display form fields -->
        <tr>
            <td>Status</td>
            <td>Name</td>
            <td>Value</td>
        </tr>
        <tr>
            <td>Mandatory</td>
            <td>username:</td>
            <td><input type="text" /></td>
        </tr>
   
    </table>
</form>
---------------------------------------------------------

which is invoked from the following simple portlet:
---   portletA.java   -------------------------------------
import javax.portlet.*;
import java.io.IOException;

public class AlfrescoRegistrationPortlet extends GenericPortlet{
   
    private final String jsp_directory = "/jsp/portletA/";
   
    public void doView(RenderRequest request, RenderResponse response)
    throws IOException, PortletException{
       
        PortletContext context = super.getPortletContext();
        PortletRequestDispatcher rd = 
context.getRequestDispatcher(jsp_directory + "view_01.jsp");
        rd.include(request, response);

    }
}
---------------------------------------------------------

My portlet application structure is:
jsp/
    portletA/
          view_01.jsp
WEB-INF
    classes/
          portletA.class
    lib/
    src/
    tld/


Both jetspeed and tomcat (localhost) logs give no error trace...
But, though the portlet window is rendered, it renders no content... =/

Can anyone tell me what I'm doing wrong or if I'm missing some thing?

Thanks in advance.

Regards,
Enrique

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: JSP advice

Posted by Enrique Perez <pe...@dit.upm.es>.
Hi Aaron,

You were right, I've made a mistake writing the path to the JSPs folder :$
I've written one letter in lower-case when it should be a capital letter...

Yet, I had to change another thing. It's related to the core tag 
library... because it complaints about been unable to find the URI =/
When I commented the line where this taglib is invoked, the content 
rendered normally...

Thanks a lot,
Enrique


Aaron Evans escribió:
> Are you sure you checked *all* of tomcat's logs? Eg. catalina.log
> and/or stdout_20070328.log.
>
> If there is a problem, it should get logged somewhere.  Try an even
> SIMPLER JSP. Better yet, just include some HTML file.  Then you can at
> least rule that out as the culprit.
>
> Then I would double-check your path.
>
> HTH,
> aaron
>
> On 3/28/07, Enrique Perez <pe...@dit.upm.es> wrote:
>> Hi,
>>
>> I'm not used to JSP and I'm getting some trouble to make a portlet
>> redirect the request to a JSP.
>>
>> I've started with a very simple JSP:
>> ---   view_01.jsp   -------------------------------------
>> <%@ page contentType="text/html" %>
>> <%@ page pageEncoding="UTF-8" %>
>> <%@ page import="javax.portlet.*" %>
>>
>> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
>> <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
>>
>> <portlet:defineObjects />
>>
>> <form action="" method="post">
>>     <table>
>>         <!-- Row 1: is reserved for info -->
>>         <tr>
>>             <td colspan="3">Please, fill in the gaps with the appropiate
>> info...</td>
>>         </tr>
>>         <!-- Row 2: displays error messages -->
>>         <% int flag = 1; %>
>>         <% if (flag==1){ %>
>>         <tr>
>>             <td colspan="3">Show error message</td>
>>         </tr>
>>         <% } %>
>>         <!-- Row 3+: display form fields -->
>>         <tr>
>>             <td>Status</td>
>>             <td>Name</td>
>>             <td>Value</td>
>>         </tr>
>>         <tr>
>>             <td>Mandatory</td>
>>             <td>username:</td>
>>             <td><input type="text" /></td>
>>         </tr>
>>
>>     </table>
>> </form>
>> ---------------------------------------------------------
>>
>> which is invoked from the following simple portlet:
>> ---   portletA.java   -------------------------------------
>> import javax.portlet.*;
>> import java.io.IOException;
>>
>> public class AlfrescoRegistrationPortlet extends GenericPortlet{
>>
>>     private final String jsp_directory = "/jsp/portletA/";
>>
>>     public void doView(RenderRequest request, RenderResponse response)
>>     throws IOException, PortletException{
>>
>>         PortletContext context = super.getPortletContext();
>>         PortletRequestDispatcher rd =
>> context.getRequestDispatcher(jsp_directory + "view_01.jsp");
>>         rd.include(request, response);
>>
>>     }
>> }
>> ---------------------------------------------------------
>>
>> My portlet application structure is:
>> jsp/
>>     portletA/
>>           view_01.jsp
>> WEB-INF
>>     classes/
>>           portletA.class
>>     lib/
>>     src/
>>     tld/
>>
>>
>> Both jetspeed and tomcat (localhost) logs give no error trace...
>> But, though the portlet window is rendered, it renders no content... =/
>>
>> Can anyone tell me what I'm doing wrong or if I'm missing some thing?
>>
>> Thanks in advance.
>>
>> Regards,
>> Enrique
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
>> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: JSP advice

Posted by Aaron Evans <aa...@gmail.com>.
Are you sure you checked *all* of tomcat's logs? Eg. catalina.log
and/or stdout_20070328.log.

If there is a problem, it should get logged somewhere.  Try an even
SIMPLER JSP. Better yet, just include some HTML file.  Then you can at
least rule that out as the culprit.

Then I would double-check your path.

HTH,
aaron

On 3/28/07, Enrique Perez <pe...@dit.upm.es> wrote:
> Hi,
>
> I'm not used to JSP and I'm getting some trouble to make a portlet
> redirect the request to a JSP.
>
> I've started with a very simple JSP:
> ---   view_01.jsp   -------------------------------------
> <%@ page contentType="text/html" %>
> <%@ page pageEncoding="UTF-8" %>
> <%@ page import="javax.portlet.*" %>
>
> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
> <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
>
> <portlet:defineObjects />
>
> <form action="" method="post">
>     <table>
>         <!-- Row 1: is reserved for info -->
>         <tr>
>             <td colspan="3">Please, fill in the gaps with the appropiate
> info...</td>
>         </tr>
>         <!-- Row 2: displays error messages -->
>         <% int flag = 1; %>
>         <% if (flag==1){ %>
>         <tr>
>             <td colspan="3">Show error message</td>
>         </tr>
>         <% } %>
>         <!-- Row 3+: display form fields -->
>         <tr>
>             <td>Status</td>
>             <td>Name</td>
>             <td>Value</td>
>         </tr>
>         <tr>
>             <td>Mandatory</td>
>             <td>username:</td>
>             <td><input type="text" /></td>
>         </tr>
>
>     </table>
> </form>
> ---------------------------------------------------------
>
> which is invoked from the following simple portlet:
> ---   portletA.java   -------------------------------------
> import javax.portlet.*;
> import java.io.IOException;
>
> public class AlfrescoRegistrationPortlet extends GenericPortlet{
>
>     private final String jsp_directory = "/jsp/portletA/";
>
>     public void doView(RenderRequest request, RenderResponse response)
>     throws IOException, PortletException{
>
>         PortletContext context = super.getPortletContext();
>         PortletRequestDispatcher rd =
> context.getRequestDispatcher(jsp_directory + "view_01.jsp");
>         rd.include(request, response);
>
>     }
> }
> ---------------------------------------------------------
>
> My portlet application structure is:
> jsp/
>     portletA/
>           view_01.jsp
> WEB-INF
>     classes/
>           portletA.class
>     lib/
>     src/
>     tld/
>
>
> Both jetspeed and tomcat (localhost) logs give no error trace...
> But, though the portlet window is rendered, it renders no content... =/
>
> Can anyone tell me what I'm doing wrong or if I'm missing some thing?
>
> Thanks in advance.
>
> Regards,
> Enrique
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: JSP advice

Posted by Enrique Perez <pe...@dit.upm.es>.
Hi Brice,

As you mentioned, I didn't put any tag library definition file inside my 
portlet application since I thought some taglibs could reference an 
absolute URI...
At least, that's what I've understood when I read this page:
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPIntro9.html#wp73314

If I try to reference "|http://java.sun.com/jsp/jstl/core|", Tomcat 
localhost log complaints saying that absolute URI cannot be resolved, 
nor in web.xml or jar files deployed in the application.
What I don't understand is why it's unable to reference 
"|http://java.sun.com/jsp/jstl/core|" but it can reference 
"http://java.sun.com/portlet"... :S
I didn't include "portlet.tld", but I think it's downloaded to 
"WEB-INF/tld"...

I also thought that content-type of the page should be set since 
everytime you send something through the portlet writer without having 
specified the content-type a portlet exception arises.
But I think it does not affect, because the content is rendered though I 
set the page content-type...

Thanks for the help.

Regards,
Enrique

Brice Lambi escribió:
> In your file system diagram, you didn't show anything under WEB-INF/lib.
> Do you have the tag library jar files in there, or in your container
> somewhere?  Also, you could put a try/catch around where you use the
> dispatcher, then manually print any exceptions that you catch.  This
> might give you a clue as to whether the jsp is compiled and rendered
> successfully.
>
> I don't think this would affect the problem you are having, but I
> believe that the content type should be determined by the portal, so
> setting the content type to 'text/html' is unnecessary.  I could be
> wrong about this, but I think you should specify content types in
> portlet.xml, because your JSP is just a fragment and does not represent
> the entire document.  Perhaps the same with encoding.
>
> Brice
>
>
> On Wed, 2007-03-28 at 18:53 +0200, Enrique Perez wrote:
>   
>> Hi,
>>
>> I'm not used to JSP and I'm getting some trouble to make a portlet 
>> redirect the request to a JSP.
>>
>> I've started with a very simple JSP:
>> ---   view_01.jsp   -------------------------------------
>> <%@ page contentType="text/html" %>
>> <%@ page pageEncoding="UTF-8" %>
>> <%@ page import="javax.portlet.*" %>
>>
>> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
>> <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
>>
>> <portlet:defineObjects />
>>
>> <form action="" method="post">
>>     <table>
>>         <!-- Row 1: is reserved for info -->
>>         <tr>
>>             <td colspan="3">Please, fill in the gaps with the appropiate 
>> info...</td>
>>         </tr>
>>         <!-- Row 2: displays error messages -->
>>         <% int flag = 1; %>
>>         <% if (flag==1){ %>
>>         <tr>
>>             <td colspan="3">Show error message</td>
>>         </tr>
>>         <% } %>
>>         <!-- Row 3+: display form fields -->
>>         <tr>
>>             <td>Status</td>
>>             <td>Name</td>
>>             <td>Value</td>
>>         </tr>
>>         <tr>
>>             <td>Mandatory</td>
>>             <td>username:</td>
>>             <td><input type="text" /></td>
>>         </tr>
>>    
>>     </table>
>> </form>
>> ---------------------------------------------------------
>>
>> which is invoked from the following simple portlet:
>> ---   portletA.java   -------------------------------------
>> import javax.portlet.*;
>> import java.io.IOException;
>>
>> public class AlfrescoRegistrationPortlet extends GenericPortlet{
>>    
>>     private final String jsp_directory = "/jsp/portletA/";
>>    
>>     public void doView(RenderRequest request, RenderResponse response)
>>     throws IOException, PortletException{
>>        
>>         PortletContext context = super.getPortletContext();
>>         PortletRequestDispatcher rd = 
>> context.getRequestDispatcher(jsp_directory + "view_01.jsp");
>>         rd.include(request, response);
>>
>>     }
>> }
>> ---------------------------------------------------------
>>
>> My portlet application structure is:
>> jsp/
>>     portletA/
>>           view_01.jsp
>> WEB-INF
>>     classes/
>>           portletA.class
>>     lib/
>>     src/
>>     tld/
>>
>>
>> Both jetspeed and tomcat (localhost) logs give no error trace...
>> But, though the portlet window is rendered, it renders no content... =/
>>
>> Can anyone tell me what I'm doing wrong or if I'm missing some thing?
>>
>> Thanks in advance.
>>
>> Regards,
>> Enrique
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
>> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>>
>>     
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: JSP advice

Posted by Brice Lambi <la...@gmail.com>.
In your file system diagram, you didn't show anything under WEB-INF/lib.
Do you have the tag library jar files in there, or in your container
somewhere?  Also, you could put a try/catch around where you use the
dispatcher, then manually print any exceptions that you catch.  This
might give you a clue as to whether the jsp is compiled and rendered
successfully.

I don't think this would affect the problem you are having, but I
believe that the content type should be determined by the portal, so
setting the content type to 'text/html' is unnecessary.  I could be
wrong about this, but I think you should specify content types in
portlet.xml, because your JSP is just a fragment and does not represent
the entire document.  Perhaps the same with encoding.

Brice


On Wed, 2007-03-28 at 18:53 +0200, Enrique Perez wrote:
> Hi,
> 
> I'm not used to JSP and I'm getting some trouble to make a portlet 
> redirect the request to a JSP.
> 
> I've started with a very simple JSP:
> ---   view_01.jsp   -------------------------------------
> <%@ page contentType="text/html" %>
> <%@ page pageEncoding="UTF-8" %>
> <%@ page import="javax.portlet.*" %>
> 
> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
> <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
> 
> <portlet:defineObjects />
> 
> <form action="" method="post">
>     <table>
>         <!-- Row 1: is reserved for info -->
>         <tr>
>             <td colspan="3">Please, fill in the gaps with the appropiate 
> info...</td>
>         </tr>
>         <!-- Row 2: displays error messages -->
>         <% int flag = 1; %>
>         <% if (flag==1){ %>
>         <tr>
>             <td colspan="3">Show error message</td>
>         </tr>
>         <% } %>
>         <!-- Row 3+: display form fields -->
>         <tr>
>             <td>Status</td>
>             <td>Name</td>
>             <td>Value</td>
>         </tr>
>         <tr>
>             <td>Mandatory</td>
>             <td>username:</td>
>             <td><input type="text" /></td>
>         </tr>
>    
>     </table>
> </form>
> ---------------------------------------------------------
> 
> which is invoked from the following simple portlet:
> ---   portletA.java   -------------------------------------
> import javax.portlet.*;
> import java.io.IOException;
> 
> public class AlfrescoRegistrationPortlet extends GenericPortlet{
>    
>     private final String jsp_directory = "/jsp/portletA/";
>    
>     public void doView(RenderRequest request, RenderResponse response)
>     throws IOException, PortletException{
>        
>         PortletContext context = super.getPortletContext();
>         PortletRequestDispatcher rd = 
> context.getRequestDispatcher(jsp_directory + "view_01.jsp");
>         rd.include(request, response);
> 
>     }
> }
> ---------------------------------------------------------
> 
> My portlet application structure is:
> jsp/
>     portletA/
>           view_01.jsp
> WEB-INF
>     classes/
>           portletA.class
>     lib/
>     src/
>     tld/
> 
> 
> Both jetspeed and tomcat (localhost) logs give no error trace...
> But, though the portlet window is rendered, it renders no content... =/
> 
> Can anyone tell me what I'm doing wrong or if I'm missing some thing?
> 
> Thanks in advance.
> 
> Regards,
> Enrique
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: JSP advice

Posted by Bob Song <da...@gmail.com>.
Hi, Enrique. 

It seems that you should use the url genearated by <portlet:renderURL />, that is:
 <form action="<portlet:renderURL />" method="post" >

And I think there are at least two differences between portlet and servlet request dispatching model:

1. In portlet model, requests have been divided into two kinds: action and render. The request to the former do not automately pass the parameters to render phrase of the same portlet.

2. Every request url should be made by the tags 'renderUrl' or  'actionUrl', which make sure the request is directed to the same portlet. 

For more information, please check relative documents like JSR-168 and a book named Portlets and Apache Portal published by Manning.

Bob Song
2007-03-30



发件人: Enrique Perez
发送时间: 2007-03-29 00:54:00
收件人: Jetspeed Users List
抄送: 
主题: JSP advice

Hi,

I'm not used to JSP and I'm getting some trouble to make a portlet 
redirect the request to a JSP.

I've started with a very simple JSP:
---   view_01.jsp   -------------------------------------
<%@ page contentType="text/html" % >
<%@ page pageEncoding="UTF-8" % >
<%@ page import="javax.portlet.*" % >

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" % >
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" % >

<portlet:defineObjects / >

<form action="" method="post" >
     <table >
         <!-- Row 1: is reserved for info -- >
         <tr >
             <td colspan="3" >Please, fill in the gaps with the appropiate 
info... </td >
         </tr >
         <!-- Row 2: displays error messages -- >
         <% int flag = 1; % >
         <% if (flag==1){ % >
         <tr >
             <td colspan="3" >Show error message </td >
         </tr >
         <% } % >
         <!-- Row 3+: display form fields -- >
         <tr >
             <td >Status </td >
             <td >Name </td >
             <td >Value </td >
         </tr >
         <tr >
             <td >Mandatory </td >
             <td >username: </td >
             <td > <input type="text" / > </td >
         </tr >
   
     </table >
</form >
---------------------------------------------------------

which is invoked from the following simple portlet:
---   portletA.java   -------------------------------------
import javax.portlet.*;
import java.io.IOException;

public class AlfrescoRegistrationPortlet extends GenericPortlet{
   
    private final String jsp_directory = "/jsp/portletA/";
   
    public void doView(RenderRequest request, RenderResponse response)
    throws IOException, PortletException{
       
        PortletContext context = super.getPortletContext();
        PortletRequestDispatcher rd = 
context.getRequestDispatcher(jsp_directory + "view_01.jsp");
        rd.include(request, response);

    }
}
---------------------------------------------------------

My portlet application structure is:
jsp/
    portletA/
          view_01.jsp
WEB-INF
    classes/
          portletA.class
    lib/
    src/
    tld/


Both jetspeed and tomcat (localhost) logs give no error trace...
But, though the portlet window is rendered, it renders no content... =/

Can anyone tell me what I'm doing wrong or if I'm missing some thing?

Thanks in advance.

Regards,
Enrique

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org