Community articleSample JSP Page
Added by IBM contributorIBM on May 2, 2012
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

No abstract provided.



The following source code creates a simple JSP page containing an XFDL form. In this example, the JSP scriptlet obtains the current date and converts it into a string. The form contains an XFDL label item that displays the string.
<?xml version="1.0"?>
  <%-- Set the content-type so that the Web browser uses the 
       Viewer to display the XFDL form. --%>
  <% response.setContentType("application/x-xfdl"); %>
	
  <%@ page import="java.util.Date" %>
  <%-- This is the JSP scriptlet --%>
	
  <%
        Date theDate = new Date();
        String theDateString = theDate.toString();
  %>
	
  <%-- The following XFDL code defines the form --%>
 
<XFDL xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom" 
      xmlns:designer="http://www.ibm.com/xmlns/prod/workplace/forms/designer/2.6" 
      xmlns:ev="http://www.w3.org/2001/xml-events" 
      xmlns:xfdl="http://www.ibm.com/xmlns/prod/XFDL/7.6" 
      xmlns:xforms="http://www.w3.org/2002/xforms" 
      xmlns="http://www.ibm.com/xmlns/prod/XFDL/7.6" 
      xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <globalpage sid="global">
    <global sid="global">
      <designer:date>20100129</designer:date>
        <formid>
          <title></title>
            <serialnumber>9710555EEBA829D8:-11895BD9:1267B9B3652:-8000</serialnumber>
            <version>1.0.0</version>
        </formid>
        <history>
          <editors>
            <editor minversion="3.5" version="3.5.1">IBM Forms Designer</editor>
          </editors>
        </history>
      </global>
  </globalpage>
  <page sid="PAGE1">
    <global sid="global">
      <label>PAGE1</label>
    </global>
    <label sid="LABEL1">
      <itemlocation>
        <x>15</x>
        <y>15</y>
      </itemlocation>
      <value><%= theDateString%></value>
    </label>
    <spacer sid="vfd_spacer">
      <itemlocation>
        <x>960</x>
        <y>1260</y>
        <width>1</width>
        <height>1</height>
      </itemlocation>
    </spacer>
  </page>
</XFDL>


Parent topic:
JSP Sample Application