Here is the code. I hope that it will be understandable for you.


<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);
%>.MARCH 20, 2000 59
<%-- 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>






Diwakar Killamsetty <[EMAIL PROTECTED]> on 07/13/2000 06:16:50 AM

Please respond to A mailing list about Java Server Pages specification and
      reference <[EMAIL PROTECTED]>

To:   [EMAIL PROTECTED]
cc:    (bcc: Abubakar Zaki/Internal/Softworks)

Subject:  How to call EJBean from JSP?




Hi,

I am novice to these technologies.
I have an EJBean on one machine and JSPs on other, now if I want to use the
services of EJBean, I need to make a JNDI call. Can any one please let me
know the procedure? And also how to write a deployment discriptor. Are they
any tutorials on web to explain all these things?
Please help me.

Thanks in advance.

regards,
Diwakar

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to