<%@ page import="oracle.portal.provider.v1.*,oracle.portal.provider.v1.http.*,
                 java.text.SimpleDateFormat,
                 java.util.Date" %>

<%
    PortletRenderRequest portletRequest = (PortletRenderRequest) request.getAttribute("oracle.portal.PortletRenderRequest");

    ProviderUser user = portletRequest.getUser();

    // set the content type for multibyte support
    String encoding = portletRequest.getCharacterEncoding();
    String contentType = "text/html;charset=" + encoding;
    response.setContentType(contentType);
%>

Hello <i><%=user.getName()%></i>.
<p>
This portlet hangs for up to 3 minutes, checking every 10 seconds
 until it exceeds its maximum execution time when it will exit.
<p>
<%
    if (portletRequest instanceof PortletExecutionTracker)
    {
        PortletExecutionTracker tracker = (PortletExecutionTracker)portletRequest;

        long startTime = tracker.getPortletStartTime();
        Date startDate = new Date(startTime);
        SimpleDateFormat sdf = new SimpleDateFormat();
        out.println("<br/>Started portlet execution at: " + sdf.format(startDate));
        out.println("<br/>Portlet warning timeout set to: " + tracker.getPortletTimeout());
        
        boolean bExit = false;
        int i = 0; 
        while ((i++ < 18) && (bExit == false))
        {
            Thread.sleep(10000);
            if (portletRequest instanceof PortletExecutionTracker)
            { 
                if (tracker.hasPortletTimeoutElapsed())
                {
                    out.println("<p>Portlet execution time has exceeded its max value - check provider log for details.");
                    bExit = true;
                }
            }
        }
    } 
%>
