<%@ page import="oracle.portal.provider.v2.render.PortletRenderRequest,
                 oracle.portal.provider.v2.ProviderUser,
                 oracle.portal.provider.v2.PortletInstance,
                 oracle.portal.provider.v2.http.HttpCommonConstants,
                 java.util.Date,
                 java.text.SimpleDateFormat" %>

<%
    PortletRenderRequest portletRequest = (PortletRenderRequest)request.
                      getAttribute(HttpCommonConstants.PORTLET_RENDER_REQUEST);

    ProviderUser user = portletRequest.getUser();
%>

Hello <i><%=user.getName()%></i>.
<p>
This portlet hangs for up to 3 minutes, checking every 10 seconds
 until it exceeds the warning execution timeout when the code exits. The 
 timeout in the provider property file is set deliberately high so that the 
 portlet progress is shown in the portal page.
<p>
<%
    boolean bExit = false;
    int i = 0;

    PortletInstance pi = portletRequest.getPortletInstance();

    long startTime = System.currentTimeMillis();
    Date startDate = new Date(startTime);
    SimpleDateFormat  sdf = new SimpleDateFormat();

    out.println("<br/>Started processing at: " + sdf.format(startDate));
    
    while ((i++ < 18) && (bExit == false))
    {
        Thread.sleep(10000);
        out.println("<br/>Time elapsed: " + 
                  (System.currentTimeMillis() - startTime)/1000 + " seconds.");
        
        if (pi.hasTimeoutElapsed())
        {
            out.println("<p>Portlet execution time has exceeded the warning timeout - check provider log for details.");
            bExit = true;
        }
    } 
%>
