badDisplayCompte2.jsp
1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<%@ 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>