Source of Cities.jsp

<%@ page contentType="text/html;charset=WINDOWS-1252"%>

<%@ page import="java.util.*, HeaderBean" %>
<%@ page import="CityDetails" %>
<%--

    @author  Savitha
    @version 1.1

    Development Environment        :  Oracle9i JDeveloper

    Name of the Application        :  Cities.jsp

    Creation/Modification History  :

       Savitha   06-Sept-2000      Created

       Srinivas  04-Jan-2002       Updated  For OC4J2.0

    Overview of Application        :

       This jsp sample displays list of Cities in a HTML table. It gets
       the list of cities and the country name from the Request object

       forwarded from the Servlet. For this, the class CityDetails is
       instantiated to get an object of that type. getCities method from
       the CountriesCitiesBean will generate the list of cities of CityDetails
       type. A HTML page having table with three columns using the class
       CityDetails is generated in this jsp.

       The servlet: ServletCallingJsp redirects its result to this JSP to

       display all the cities with its details rendered in a HTML table.
       This jsp uses the HeaderBean to display its banner.

--%>

<jsp:useBean id="CountriesCitiesBean" class="CountriesCitiesBean" scope="session" />

<HTML>

 <TITLE>OC4J JSP sample : List of Cities Redirected From Servlet</TITLE>
  <BODY background="../images/Background.gif"><BR>
   <%-- Declare the java variables to store list of Cities and country name --%>
   <%! CityDetails[] cityNames = null; %>
   <%! String countryName = null; %>
   <%! int length = 0; %>
   <%! int index  = 0; %>

   <%-- Get the city names and country name from the request object --%>

   <%   cityNames = (CityDetails[]) request.getAttribute("cities"); %>
   <% countryName = (String) request.getAttribute("countryName"); %>

   <CENTER>
     <%--
       loop through the cities and generate a table with these names
     --%>
     <% StringBuffer l_sb = null;
        // Display banner and the table header only when cities are found.
        if (cityNames.length != 0){

          l_sb = new StringBuffer();

          // Add Banner using HeaderBean
          HeaderBean l_banner = new HeaderBean();
          l_banner.setData(" List of Cities in : "+countryName);
          l_sb.append(l_banner.setBanner());
     %>
     <%=l_sb.toString()%>
     <BR>
     <!-- Display City Details in HTML table -->
      <TABLE BORDER BGCOLOR="#C4FFFF" ALIGN=CENTER>

       <TR>
        <TH BGCOLOR="#000080">
         <FONT COLOR=WHITE>
          <I>City Name</I>
         </FONT>
        </TH>
        <TH BGCOLOR="#000080">
         <FONT COLOR=WHITE>
          <I>State Province</I>
         </FONT>
        </TH>
        <TH BGCOLOR="#000080">

         <FONT COLOR=WHITE>
          <I>Time Zone To Gmt</I>
         </FONT>
        </TH>
       </TR>
      <% }else { %>
      <%-- Display message when no cities found for the selected country --%>
            <TABLE BGCOLOR="BLACK" ALIGN=CENTER WIDTH=100%>
             <TR><TH><CENTER><FONT COLOR=RED SIZE=3>
                 No Cities found. Select another Country.</FONT></CENTER>
             </TH></TR>
            </TABLE>
      <%}

         for (int i = 0; i < cityNames.length; i++) {
      %>
      <TR>
        <TD><%= cityNames[i].m_cityName %></TD>
        <TD><%= cityNames[i].m_StateProvince %></TD>
        <TD><%= cityNames[i].m_TimeZoneToGmt %></TD>
      </TR>
      <% }
         %>
     </TABLE>
     <BR>
    <FORM>
     <CENTER>
      <INPUT type=button name=Back value=Back onClick="history.go(-1)">

     </CENTER>
    </FORM>
 </BODY>
</HTML>


E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy