badDisplayCompte2.jsp 1.09 KB
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>demo JSP</title>
</head>

<%@ page import="javax.ejb.*" %>
<%@ page import="javax.naming.*" %>
<%@ page import="ejb.sessions.ServiceBanqueLocal" %>
<%@ page import="ejb.entites.Compte" %>
<%@ page import="ejb.sessions.CompteInconnuException" %>
<%!
 Compte c ;
 int numeroCompte ;
%>
<body>
<%
 numeroCompte=Integer.parseInt(request.getParameter("numeroCompte")) ;
 Compte c=null ;
 InitialContext ic = new InitialContext();
 Object obj = ic.lookup("java:app/appliBanqueSessions/ServiceBanqueBean!ejb.sessions.ServiceBanqueLocal");
 ServiceBanqueLocal  service= (ServiceBanqueLocal) obj ;
 try {
   c=service.getCompte(numeroCompte) ;
%>
 <h2>Compte <%= numeroCompte%></h2>
 <ul><li>Titulaire:<b><%= c.getTitulaire() %></b></li>
     <li>Solde:<b><%= c.getSolde() %></b></li>
 </ul> 		
<%   } catch (CompteInconnuException e) { %>
  <h2>Compte <%= numeroCompte %> inconnu</h2> ;
<%   } // fin du try catch %>
</body>
</html>