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

<%
    response.setContentType("text/html;charset=UTF-8"); 

    // The form submit URL refers to the current Portal page.  All portlets
    // on this page share this URL.  This means that the per portlet parameters
    // are in the same request.  Portlets must ensure that its paramerters don't
    // collide either with other portlets or other instances of itself.  This
    // is generally accomplished by using "fully-qualified" parameter names. A
    // fully-qualified parameter name prepends the (unique) portlet reference to
    // the parameter.  The JPDK provides a utility to accomplish this.

    String fName = HttpPortletRendererUtil.portletParameter(request, "mName");
    String fAge  = HttpPortletRendererUtil.portletParameter(request, "mAge");
    String fSubmit = HttpPortletRendererUtil.portletParameter(request, "mSubmit");

    // These are the session attribute names used to store the current values.
    // Because all instances of this portlet share the same user session we must
    // also fully-qualify these names to avoid collisions.

    String sName = HttpPortletRendererUtil.portletParameter(request, "sName");
    String sAge  = HttpPortletRendererUtil.portletParameter(request, "sAge");


    // Record, in session storage, the last values submitted.
    if (request.getParameter(fSubmit) != null)
    {
       session.putValue(sName, request.getParameter(fName));
       session.putValue(sAge, request.getParameter(fAge));
    }
%>

<!-- Output the HTML content -->

<center>

<table width="70%">
  <tr>
     <td>
         <b>This portlet shows how to post and process information from HTML forms.</b>
     </td>
  </tr>
</table>

<form method="POST" action="<%= HttpPortletRendererUtil.htmlFormActionLink(request,PortletRendererUtil.PAGE_LINK) %>">

<%= HttpPortletRendererUtil.htmlFormHiddenFields(request,PortletRendererUtil.PAGE_LINK) %>

<table>
   <tr>
      <td>
         <b>Name :</b>
      </td>
      <td>
         <input type="text" size="20" name="<%= fName %>" value="">
      </td>
   </tr>
   <tr>
      <td>
         <b>Age : </b>
      </td>
      <td>
         <input type="text" size="3" name="<%= fAge %>" value="">
      </td>
   </tr>
</table>

<br>

<INPUT TYPE=submit name="<%= fSubmit %>" Value="Submit">

</form>

<%
if ((session.getValue(sName) == null)&& (session.getValue(sAge) == null)) {
%>
   <b>No values have been submitted yet.</b>
<%
} else {
%>
   <b> Last submitted values:</b><br>

   <table>
      <tr>
         <td>
            <b>Name: </b>
         </td>
         <td>
            <b><%= session.getValue(sName) %></b>
         </td>
      </tr>
      <tr>
         <td>
            <b>Age: </b>
         </td>
         <td>
            <b><%= session.getValue(sAge) %></b>
         </td>
      </tr>
   </table>
<%
}
%>

</center>

<!-- End output the HTML content -->
