01 <%@ page contentType="text/html; charset=Shift_JIS" %>
02 <%@ page import="javax.naming.*,
03 java.text.*,
04 java.util.*, org.jboss.security.*,
05 trail.entity.beans.*, trail.security.*,
06 java.security.Principal"%>
07
08 <%!
09 private Calculator cal = null;
10 private NumberFormat nf = null;
11
12 public void jspInit () {
13 try {
14 InitialContext ctx = new InitialContext();
15 cal = (Calculator) ctx.lookup(
16 "EJB3Trail/SecureCalculator/local");
17 } catch (Exception e) {
18 e.printStackTrace ();
19 }
20
21 nf = NumberFormat.getInstance();
22 nf.setMaximumFractionDigits(2);
23 }
24 %>
25
26 <html>
27
28 <%
29 if ("AddInvestor".equals(request.getParameter("action"))) {
30 try {
31 cal.addInvestor (request.getParameter("investorname"),
32 Integer.parseInt(request.getParameter("investorstart")),
33 Integer.parseInt(request.getParameter("investorend")));
34 } catch (Exception e) {
35 %>
36 <head><meta http-equiv="REFRESH" content="0; URL=error.html"></head>
37 <%
38 return;
39 }
40 } else if ("Logout".equals(request.getParameter("action"))) {
41 ((HttpSession) request.getSession()).invalidate ();
42 SecurityAssociation.clear ();
43 %>
44 <head><meta http-equiv="REFRESH" content="0; URL=addinvestor.jsp"></head>
45 <%
46 return;
47 }
48 %>
49
50 <body>
51
52 <p><form action="addinvestor.jsp" method="POST">
53 現在のユーザは <b><%=((Principal) SecurityAssociation.getPrincipal()).getName()%></b> です
54 <input type="hidden" name="action" value="Logout"><br/>
55 <input type="submit" value="ユーザを変更する">
56 </form></p>
57
58 <p>個人投資家を追加する:<br/>
59 <form action="addinvestor.jsp" method="POST">
60 名前 : <input type="text" name="investorname" value=""><br/>
61 開始年齢 = <input type="text" name="investorstart" value="25">
62 終了年齢 = <input type="text" name="investorend" value="65">
63 <input type="hidden" name="action" value="AddInvestor"><br/>
64 <input type="submit" value="個人投資家を追加する">
65 <INPUT type="button" value="閉じる" onClick="window.close()">
66 </form><br/>
67
68 <%
69 // Collection <Investor> investors = cal.getInvestors();
70 Collection investors = cal.getInvestors();
71 %>
72
73 <b><%=investors.size()%></b>人の個人投資家がデータベースに登録されています。<br/>
74
75 <table>
76 <tr>
77 <td>名前</td>
78 <td>開始年齢</td>
79 <td>終了年齢</td>
80 </tr>
81
82 <%
83 for (Iterator iter = investors.iterator(); iter.hasNext();) {
84 Investor investor = (Investor) iter.next();
85 %>
86
87 <tr>
88 <td><%=investor.getName()%></td>
89 <td><%=investor.getStartAge()%></td>
90 <td><%=investor.getEndAge()%></td>
91 </tr>
92
93 <%
94 }
95 %>
96 </table></p>
97
98 </body></html>
|