?? bonus.jsp
字號:
<%-- Comment HTML code to start HTML page and body --%><HTML><HEAD><TITLE>Bonus Calculation</TITLE></HEAD> <%-- Comment Scriptlet for import statements <%@ indicates a jsp directive --%> <%@ page import="javax.naming.*" %> <%@ page import="javax.rmi.PortableRemoteObject" %> <%@ page import="Beans.*" %> <%-- Comment Scriptlet to get the parameters, convert string to Integer to int for bonus calculation, and declare/initialize bonus variable. <% indicates a jsp scriptlet --%> <%! String strMult, socsec; %> <%! Integer integerMult; %> <%! int multiplier; %> <%! double bonus; %><% strMult = request.getParameter("MULTIPLIER"); socsec = request.getParameter("SOCSEC"); integerMult = new Integer(strMult); multiplier = integerMult.intValue(); bonus = 100.00;%> <%-- Comment Scriptlet to look up session Bean --%><% InitialContext ctx = new InitialContext(); Object objref = ctx.lookup("calcs"); CalcHome homecalc = (CalcHome)PortableRemoteObject.narrow(objref, CalcHome.class);%> <%-- Comment Scriptlet to create session Bean, call calcBonus method, and retrieve a database record by the social security number (primary key) --%><% try { Calc theCalculation = homecalc.create(); Bonus theBonus = theCalculation.calcBonus(multiplier, bonus, socsec); Bonus record = theCalculation.getRecord(socsec);%> <%-- Comment HTML code to display retrieved data on returned HTML page. --%> <H1>Bonus Calculation</H1> Social security number retrieved: <%= record.getSocSec() %> <P> Bonus Amount retrieved: <%= record.getBonus() %> <P> <%-- Comment Scriptlet to catch DuplicateKeyException --%><% } catch (javax.ejb.DuplicateKeyException e) { String message = e.getMessage();%> <%-- Comment HTML code to display original data passed to JSP on returned HTML page --%> Social security number passed in: <%= socsec %> <P> Multiplier passed in: <%= strMult %> <P> Error: <%= message %> <%-- Comment Scriptlet to close try and catch block --%><% }%> <%-- Comment HTML code to close HTML body and page --%></BODY></HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -