Image

JSP Error

Hi, I've this JSP page that use a Collection to get the attributes' values. There is also a try/catch method in the code, which cause the JSP to be displayed as a blank page instead. I had wanted the [%=CM.getCourseID()%] and etc to be displayed. I believe that there is an exception hence causing the "system" to not display the items I want. I've tried looking through the codes but couldn't figure out where I went wrong. Can someone help? Thanks in advance.





<%@ page contentType="text/html; charset=iso-8859-1" language="java" %>

<%@ page import="alphapoly.CourseModule.Course.*,
		 alphapoly.CourseModule.CourseManager.*, 
		 alphapoly.CourseModule.utility.*,		
		 javax.ejb.*,
 		 javax.rmi.*, 
		 java.math.*, 
		 javax.naming.*, 
		 javax.rmi.PortableRemoteObject, 
		 java.rmi.RemoteException, 
		 java.util.*" 
%>

<%!
   private CourseManager CourseManager = null;

   public void jspInit() { 

      try {

         InitialContext ic = new InitialContext();
         Object objRef = ic.lookup ("java:comp/env/ejb/CourseManager");
         CourseManagerHome home = (CourseManagerHome) PortableRemoteObject.narrow (objRef, CourseManagerHome.class);
         CourseManager = home.create();
      
      
      } catch (ClassCastException ex) {
      	   System.out.println("Couldn't create CourseManagerBean.123 " + ex.getMessage());
      	     
      } catch (RemoteException ex) {

            System.out.println("Couldn't create CourseManager bean."+ ex.getMessage());

      } catch (CreateException ex) {

            System.out.println("Couldn't create CourseManagerr bean."+ ex.getMessage());

      } catch (NamingException ex) {

            System.out.println("Unable to lookup home: "+ "CourseManager "+ ex.getMessage());
			
      } catch (Exception ex) {
      	
      	    System.out.println("Other exceptions");
  
      }// End of Try and Catch Statements for jspInit ()

   }// End of jspInit ()

   public void jspDestroy () {

         CourseManager = null;

   }// End of jspDestroy ()
%>

<!-- ############   HTML CODES START HERE   ########## -->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="imagetoolbar" content="no">

<title>Alpha Polytechnic - Strive to Excel - Faculities</title>

<link href="../css.css" rel="stylesheet" type="text/css"/>

<SCRIPT language=JavaScript src="menu_array.js" type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript src="mmenu.js" type=text/javascript></SCRIPT>

</head>

<body>

<div style="position: absolute; top:0; left:0">
<iframe src="../topframe.jsp" name="topframe" width="800" height="200" FRAMEBORDER="0"></iframe>
</div>


<div style="position: absolute; top:140; left:10">
<img src="../images/faculties/faculties.jpg" border="0">
</div>


<div style="position:absolute;overflow:auto;width:565px;height:386px;top:130px;left:230px;text-align:justify;">
<img src="../images/faculties/chemical.gif" border="0"><br><br>


<% 	

// ############### JSP CODES STARTS HERE AGAIN ###############

try{	
	String faculty = "Chemical"; 
		
	Collection collectionList =CourseManager.viewCourseByFaculty(faculty);

	Iterator i = collectionList.iterator();
   	while (i.hasNext()) {
				CourseModel CM = (CourseModel) i.next(); %>
				
%>


<!-- ############### HTML with the JSP get attributes STARTS HERE ############ -->

<table cellpadding="2" cellspacing="1" class="grey" border="0"  bgcolor="#ADADAD" width=200>
<tr><td bgcolor="#ADADAD"><B>CourseID:</td></tr></table><br><br>

<%=CM.getCourseID()%><br/><br/><br/>

<table cellpadding="2" cellspacing="1" class="grey" border="0"  bgcolor="#ADADAD" width=200>
<tr><td bgcolor="#ADADAD"><B>Course Name:</td></tr></table><br><br>

<%=CM.getCourseName()%><br/><br/>

<table cellpadding="2" cellspacing="1" class="grey" border="0"  bgcolor="#ADADAD" width=200>
<tr><td bgcolor="#ADADAD"><B>Faculty:</td></tr></table><br><br>

<%=CM.getFaculty()%><br/><br/>


<table cellpadding="2" cellspacing="1" class="grey" border="0"  bgcolor="#ADADAD" width=200>
<tr><td bgcolor="#ADADAD"><B>Modules:</td></tr></table><br><br>

<%=CM.getModules()%><br/><br/>


....................................................<br/><br/>


<% 
   
    			} //end while 
} // end try   		
			
catch(Exception e)
{

	System.out.println("This faculty has no courses at the moment.");
		

} // end catch 

		
%>



</div>



<div style="position: absolute; top:540; left:10">

<img src="../images/bottom.jpg" border="0" usemap="#mymap">

<map name="mymap">
<area shape="rect" coords="543,10,591,20" href="../privacy.jsp" alt="privacy">
<area shape="rect" coords="605,10,667,20" href="../disclaimer.jsp" alt="disclaimer">
<area shape="rect" coords="672,10,741,20" href="../contactus.jsp" alt="disclaimer">
</map>


</div>


</body>

</html>