⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bonus.jsp

📁 J2EE 企业级培训教程,包含源码
💻 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 + -