<%
/*
 * Copyright (c) 1999-2000 BEA Systems, Inc.  All rights reserved
 *
 * THIS IS SOURCE CODE PUBLISHED FOR DEMONSTRATION PURPOSES
 *
 * This JHTML file illustrates how a University HTML client uses a servlet
 * to invoke operations on the WebLogic Enterprise University CORBA objects.
 */
%>

<%@ page import="
    com.beasys.Tobj.*,
    com.beasys.*,
    UniversityT.RegistrarFactory,
    UniversityT.RegistrarFactoryHelper,
    UniversityT.Registrar
"%>

<%
  // Code that is in the "service()" method.

  UniversityHelper univHelper= new UniversityHelper();

  // Get the Student Id 
  String studentId = (String) request.getParameter("STUDENT_ID");
  boolean validId = true;
  try {
    // Get a connection from the pool which has been initialized 
    // at the web server startup.
    univHelper.univInit();
    validId = univHelper.verifyStudent(studentId);
  
    if (validId == false)
    {
%>

      <html>
      <head><title>List Registered Courses - Application Error</title></head>
      <body bgcolor=#FFFFFF>
      <font face="Helvetica">

      <center>
      <h3>
      <font color='#FF0000'>
      Application Error
      </font>
      </h3>

      <b>Student Id:</b>
      <font color='#0000FF'>
      <%=
        request.getParameter("STUDENT_ID")
      %>
      </font>

      <form>
      <input type='button' value='Back' OnClick='history.go(-1)'>
      </form>
      <p>
      Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.
      
      </center>
      </font>
      </body>
      </html>

<%
      return;
    }
%>

    <html><head><title>List of Registered Courses </title></head>
    <body>

    <form name="registrar" action="/displayDetailsServlet.jsp" method="post">

    <center>
    <h4><B>List of Registered Courses</B></h4>

    <select name="COURSE_NUM" size=10 >

<%
    for (int index = 0; index < univHelper.gStudentDetails.registered_courses.length; index++)
    {
      if (index == 0) {
%>

        <option selected value=<%=univHelper.gStudentDetails.registered_courses[index].course_number%>><%=univHelper.gStudentDetails.registered_courses[index].course_number%>:<%=univHelper.gStudentDetails.registered_courses[index].title%></option>
<%
      }
      else {
%>
        <option value=<%=univHelper.gStudentDetails.registered_courses[index].course_number%>><%=univHelper.gStudentDetails.registered_courses[index].course_number%>:<%=univHelper.gStudentDetails.registered_courses[index].title%></option>
  
<%
      }
    }
%>

    </select>
    <br> <br>
    <input type="submit" value="Display">
    <p>
    Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.
    
    </center>
    </body></html>
<%
  }
  catch (Exception e)
  {
%>
    <html>
    <head><title>List Registered Courses - Error</title></head>
    <body bgcolor=#FFFFFF>
    <font face="Helvetica">

    <center>
    <h3>
    <font color='#FF0000'>
    System Error: <%=e.toString()%>
    </font>
    </h3>

    <form>
    <input type='button' value='Back' OnClick='history.go(-1)'>
    </form>
    <p>
    Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.
    
    </center>
    </font>
    </body>
    </html>

<%
  }
%>
