<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fouad&#039;s Blog</title>
	<atom:link href="http://www.fouad-saidy.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.fouad-saidy.com</link>
	<description>Select * From World where type=&#34;computing&#34;;</description>
	<lastBuildDate>Thu, 17 Mar 2011 14:20:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Use an Existing Web Service in VB.NET</title>
		<link>http://www.fouad-saidy.com/archives/205</link>
		<comments>http://www.fouad-saidy.com/archives/205#comments</comments>
		<pubDate>Fri, 12 Mar 2010 23:12:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DotNET]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Web service]]></category>

		<guid isPermaLink="false">http://fouad-saidy.freehostia.com/?p=205</guid>
		<description><![CDATA[The aim of the following tutorial is to give you a basic information about Web Service
 To execute the example in this tutorial you need visual studio 2005 or 2008 :
This is an express edition of visual studio 2008 VS2008
In this tutorial we will create a form that gets information from a web service about  <a href="http://www.fouad-saidy.com/archives/205" class="more-link">More &#62;</a><p><a href="http://sharethis.com/item?&#038;wp=2.8.2&#38;publisher=c52c2557-5007-4da4-b176-d174646fb516&#38;title=How+to+Use+an+Existing+Web+Service+in+VB.NET&#38;url=http%3A%2F%2Fwww.fouad-saidy.com%2Farchives%2F205">ShareThis</a></p>]]></description>
			<content:encoded><![CDATA[<p>The aim of the following tutorial is to give you a basic information about Web Service<br />
 To execute the example in this tutorial you need visual studio 2005 or 2008 :<br />
This is an express edition of visual studio 2008 <a href="http://msdn.microsoft.com/en-us/vstudio/aa700831.aspx">VS2008</a><br />
In this tutorial we will create a form that gets information from a web service about the <a href="http://euro2008.dataaccess.eu/footballpoolwebservice.wso">euro2008</a> (Europe football cup) .<br />
Firstly select a vb.net project and design a form like this:</p>
<div id="attachment_208" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/03/webservice12.jpg" rel="lightbox-205"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/03/webservice12-300x222.jpg" alt="Application Interface" title="webservice1" width="300" height="222" class="size-medium wp-image-208" /></a><p class="wp-caption-text">Application Interface</p></div><br />
In this form we will show a list of all stadiums, teams of <a href="http://euro2008.dataaccess.eu/footballpoolwebservice.wso">euro2008</a> football cup.<br />
Select a stadium and click the button Click, the application gets the city and capacity of the stadium selected in the stadium combobox from the webservice.<br />
Now let’s select the reference to the web service, right click to the service references, add a service reference.</p>
<p><div id="attachment_209" class="wp-caption aligncenter" style="width: 237px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/03/webservice2.jpg" rel="lightbox-205"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/03/webservice2-227x300.jpg" alt="Service References" title="webservice2" width="227" height="300" class="size-medium wp-image-209" /></a><p class="wp-caption-text">Service References</p></div>
<p>Secondly we will add the link of web service to our project: <strong>http://euro2008.dataaccess.eu/footballpoolwebservice.wso?WSDL</strong> , and click &#8220;go to&#8221; then wait until VB  find to webservice, now specifiy a name for the space name of the web service then click ok, the Visual Basic generates different configuration files :</p>
<div id="attachment_210" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/03/webservice3.jpg" rel="lightbox-205"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/03/webservice3-300x244.jpg" alt="Add Service References" title="webservice3" width="300" height="244" class="size-medium wp-image-210" /></a><p class="wp-caption-text">Add Service References</p></div>
<p>Now let’s write some code in the form to make the web service works correctly:</p>
<p><em>Public Class Form1<br />
‘ ServiceReference1 is the name space that you chose<br />
    Public ws As New ServiceReference2.FootballPoolWebServiceSoapTypeClient</p>
<p>    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load</p>
<p>        ‘ define the staduim_lenght and the numbers of teams<br />
        Dim stadium_lenght, Team_count As Integer</p>
<p>        stadium_lenght = ws.StadiumNames.Count<br />
        stadium_lenght -= 1</p>
<p>	‘ add names of staduims from the web service to the combobox1<br />
        For i = 0 To stadium_lenght</p>
<p>            ComboBox1.Items.Add(ws.StadiumNames.Item(i).Trim())<br />
        Next i</p>
<p>        Team_count = ws.Teams.Count<br />
        Team_count -= 1</p>
<p>        ‘add names of teams from the web service to the combobox2 </p>
<p>        For j = 0 To Team_count</p>
<p>            ComboBox2.Items.Add(ws.Teams.ElementAt(j).sName)<br />
        Next j<br />
        ComboBox1.SelectedIndex = 0<br />
        ComboBox2.SelectedIndex = 0<br />
    End Sub</p>
<p>    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click</p>
<p>‘ Select then city name, staduim name, and the capacity of the stadium ‘chosen in combobox1</p>
<p>        TextBox1.Text = ws.StadiumInfo(ComboBox1.SelectedItem.ToString()).sCityName<br />
        TextBox2.Text = ws.StadiumInfo(ComboBox1.SelectedItem.ToString()).sStadiumName<br />
        TextBox3.Text = ws.StadiumInfo(ComboBox1.SelectedItem.ToString()).iSeatsCapacity</p>
<p>    End Sub<br />
End Class</em></p>
<p>This is how the  interface application looks at executing the program:<br />
<div id="attachment_214" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/03/webservice4.jpg" rel="lightbox-205"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/03/webservice4-300x218.jpg" alt="Executing Application" title="webservice4" width="300" height="218" class="size-medium wp-image-214" /></a><p class="wp-caption-text">Executing Application</p></div></p>
<p>You created your first interaction with an existing web service  (<a href="http://euro2008.dataaccess.eu/footballpoolwebservice.wso">euro2008</a>), if you have any comments or remarks post it in my blog or alert me by email.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fouad-saidy.com/archives/205/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>How To Use XUpdate In Java With Xindice Database</title>
		<link>http://www.fouad-saidy.com/archives/26</link>
		<comments>http://www.fouad-saidy.com/archives/26#comments</comments>
		<pubDate>Sun, 07 Feb 2010 19:01:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://fouad-saidy.freehostia.com/?p=26</guid>
		<description><![CDATA[This Tutorial is available in PDF Book  : How To Use XUpdate In Java With Xindice Database
The aim of this tutorial is to show you how to develop a simple java class that use CRUD (Create Read Update Delete ) operations with an xml file stored in a native XML Database.
firstly to begin you  <a href="http://www.fouad-saidy.com/archives/26" class="more-link">More &#62;</a><p><a href="http://sharethis.com/item?&#038;wp=2.8.2&#38;publisher=c52c2557-5007-4da4-b176-d174646fb516&#38;title=How+To+Use+XUpdate+In+Java+With+Xindice+Database&#38;url=http%3A%2F%2Fwww.fouad-saidy.com%2Farchives%2F26">ShareThis</a></p>]]></description>
			<content:encoded><![CDATA[<p>This Tutorial is available in PDF Book  : <a href="http://www.scribd.com/doc/28280460/How-to-use-xupdate-in-java-with-xindice-database">How To Use XUpdate In Java With Xindice Database</a></p>
<p>The aim of this tutorial is to show you how to develop a simple java class that use CRUD (Create Read Update Delete ) operations with an xml file stored in a native XML Database.<br />
firstly to begin you should download those tools:</p>
<ul>
<li><a href="http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/SR1/eclipse-jee-galileo-SR1-win32.zip"> Eclipse Galileo </a> </li>
<li><a href="https://olex.openlogic.com/package_versions/download/4788?package_version_id=1065&#038;path=openlogic%2Fxindice%2F1.0%2Fxindice-1.0-windows-bin.zip">Xindice 1.0 DataBase</a> </li>
<li>
<a href="http://www.schatten.info/software/xindice_browser/XIndiceBrowser_bin.zip"> Xindice Browser </a> </li>
</ul>
<ol>
	<font color="blue" >
<li><strong>Launching the server and adding the XML file to the native database :</strong> </li>
<p> </font><br />
let&#8217;s begin our project ,we should create a xml file for example called  <strong>persons.xml</strong> in whish we add some  person elements ,each person has different nodes(first name,last name,email ,age) this is an example of persons.xml :</p>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> persons </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> person id=&#8221;1&#8243; </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> fname </span> <span style="color: red;">></span> <span style="color:green;">FOUAD </span> <span style="color: red;"> < </span>  <span style="color: blue;"> /fname </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> lname </span> <span style="color: red;">></span> <span style="color:green;">SAIDY </span> <span style="color: red;"> < </span>  <span style="color: blue;"> /lname </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> email</span> <span style="color: red;">></span> <span style="color:green;">fouadsaidy@gmail.com</span> <span style="color: red;"> < </span>  <span style="color: blue;"> /email </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> age</span> <span style="color: red;">></span> <span style="color:green;">22</span> <span style="color: red;"> < </span>  <span style="color: blue;"> /age </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> /person </span> <span style="color: red;"> > </span>
</div>
<p><!-- Person 2--></p>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> person id=&#8221;2&#8243; </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> fname </span> <span style="color: red;">></span> <span style="color:green;">KEVIN </span> <span style="color: red;"> < </span>  <span style="color: blue;"> /fname </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> lname </span> <span style="color: red;">></span> <span style="color:green;">MITNICK </span> <span style="color: red;"> < </span>  <span style="color: blue;"> /lname </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> email</span> <span style="color: red;">></span> <span style="color:green;">kevin.mitnick@gmail.com</span> <span style="color: red;"> < </span>  <span style="color: blue;"> /email </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> age</span> <span style="color: red;">></span> <span style="color:green;">45</span> <span style="color: red;"> < </span>  <span style="color: blue;"> /age </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> /person </span> <span style="color: red;"> > </span>
</div>
<p><!-- Person 3--></p>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> person id=&#8221;3&#8243; </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> fname </span> <span style="color: red;">></span> <span style="color:green;">BILL </span> <span style="color: red;"> < </span>  <span style="color: blue;"> /fname </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> lname </span> <span style="color: red;">></span> <span style="color:green;">GATES </span> <span style="color: red;"> < </span>  <span style="color: blue;"> /lname </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> email</span> <span style="color: red;">></span> <span style="color:green;">bill.gates@gmail.com</span> <span style="color: red;"> < </span>  <span style="color: blue;"> /email </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> age</span> <span style="color: red;">></span> <span style="color:green;">55</span> <span style="color: red;"> < </span>  <span style="color: blue;"> /age </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> /person </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> /persons </span> <span style="color: red;"> > </span>
</div>
<p>We created the xml file let&#8217;s now store this file in <strong>Xindice database</strong> ,to do that we should start the server, open the  Xindice Folder called xindice-1.0 &#8211;>launch  startup.bat, to verify if the server is executed correctly open your navigator and show <strong>http://localhost:4080/</strong>  page if you saw an xindice page that means the server is launched without errors.</p>
<div id="attachment_97" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice0.jpg"  rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice0.jpg" alt="The Server Is Running" title="xindice0" width="400" height="200" class="size-full wp-image-97" /></a><p class="wp-caption-text">The Server Is Running</p></div>
<div id="attachment_110" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice6.jpg"  rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice6-1024x289.jpg" alt="Apache XIndice Start Page " title="xindice6" width="400" height="200" class="size-large wp-image-110" /></a><p class="wp-caption-text">Apache XIndice Start Page </p></div>
<p>Next step is to launch Xindice Browser which give us many options to look to the database (open XindiceBrowser and execute <strong>XIndiceBrowser.bat</strong><br />
To add the Xml file to the XML database we should create a Collection in whish we will store this  file:</p>
<div id="attachment_123" class="wp-caption aligncenter" style="width: 350px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice2.jpg"  rel="lightbox-26"> <img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice2-300x135.jpg" alt="Create a Test Collection" title="xindice2" width="340" height="240" class="size-medium wp-image-123" /></a><p class="wp-caption-text">Create a Test Collection</p></div>
<p>Now let&#8217;s add <strong>persons.xml</strong> file to the new collection :<br />
<div id="attachment_120" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice3.jpg" rel="lightbox-26"> <img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice3-300x135.jpg" alt="Add XML File To Test Collection" title="xindice3" width="400" height="200" class="size-medium wp-image-120" /></a> <p class="wp-caption-text">Add XML File To Test Collection</p></div></p>
<div id="attachment_141" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice4.jpg"  rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice4-300x89.jpg" alt="Add persons.xml to Test collection" title="xindice4" width="300" height="89" class="size-medium wp-image-141" /></a><p class="wp-caption-text">Add persons.xml to Test collection</p></div>
<div id="attachment_142" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice5.jpg" rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice5-300x112.jpg" alt="show persons.xml in XIndice Browser" title="xindice5" width="300" height="112" class="size-medium wp-image-142" /></a><p class="wp-caption-text">show persons.xml in XIndice Browser</p></div>
<p>we finished the first step of configuration and insertion of XML file in native database,next step is to create a javaa classe wishes manipulate the XML file stored in the database.<br />
     <font color="blue" >
<li>   <strong>Update XML database in java</strong> </li>
<p> </font><br />
open Eclipse Galileo IDE and create a new Java Project called <strong>test_xindice</strong> ,click the right mouse into the project and select Properties , in the properties window select Java Build Path &#8211;> Libraries , then  click the <strong> Add External JARs&#8230;</strong>  Button , select the 5 jar&#8217;s in the java&#8211;> lib folder (see the next image) </p>
<div id="attachment_140" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice7.jpg" rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice7-300x200.jpg" alt="Add Jars To Java Project" title="xindice7" width="300" height="200" class="size-medium wp-image-140" /></a><p class="wp-caption-text">Add Jars To Java Project</p></div><br />
<div id="attachment_142" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice5.jpg" rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice5-300x112.jpg" alt="show persons.xml in XIndice Browser" title="xindice5" width="300" height="112" class="size-medium wp-image-142" /></a><p class="wp-caption-text">show persons.xml in XIndice Browser</p></div> classe called xupdate and add this code to your class :<br />
<a href='http://www.fouad-saidy.com/wp-content/uploads/2010/02/xupdate.java'>Download xupdate.java</a><br />
to execute this class we should modify the run configuration of the eclipse IDE to do that select in principal menu run&#8211;>run configuration&#8211;>Arguments , enter one of this arguments:</p>
<ul>
<li> add a new person           : <strong>-A persons farid safiri 25 farid@gmail.com</strong> </li>
<li> Remove the 4th person    :  <strong>-R persons 4</strong></li>
<li>update the second person : <strong> -E persons 2 steve Mcarty 21 sMcarty@gmail.com</strong>
</ul>
<p>after writhing one of those case in the argument section click run, you will see the xupdate code in the eclipse console, for example if we write the first option adding a new person to the <strong>persons.xml</strong> file stored in the database we will see the request like this :</p>
<p><div id="attachment_174" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice8.jpg" rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice8-300x172.jpg" alt="add Arguments to Eclipse run configuration" title="xindice8" width="300" height="172" class="size-medium wp-image-174" /></a><p class="wp-caption-text">add Arguments to Eclipse run configuration</p></div>
<p>The code produced by the program and executed in the server :<br />
<div id="attachment_192" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice9.jpg" rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice9-300x111.jpg" alt="XUpdate code sent to the server " title="xindice9" width="300" height="111" class="size-medium wp-image-192" /></a><p class="wp-caption-text">XUpdate code sent to the server </p></div></p>
<p>for more informations about how to use  <a href="http://www.xmldatabases.org/projects/XUpdate-UseCases/">XUpdate UseCases</a>  </p>
<p>now let&#8217;s see the modification in Xml database, move to XIndice Database Browser click the refresh button and select persons.xml file you will see that the forth person is added to the database :<br />
<div id="attachment_194" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice10.jpg" rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice10-300x176.jpg" alt="XML Database updated" title="xindice10" width="300" height="176" class="size-medium wp-image-194" /></a><p class="wp-caption-text">XML Database updated</p></div></p>
<p>In the same way you can execute author options  of removing or updating an element in the XML database .</p>
<p>	 <font color="blue" >
<li><strong>Execute XPath expression in java</strong> </li>
<p> </font><br />
To learn XPath : <a href="http://www.w3schools.com/XPath/default.asp">XPath Tutorial </a></p>
<p>create a simple java class called show_xml and copy this file to your class:<br />
<a href='http://www.fouad-saidy.com/wp-content/uploads/2010/02/show_xml.java'>show_xml.java</a><br />
execute this file and you will see the result in eclipse console like this :<br />
<div id="attachment_199" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice11.jpg" rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice11-300x73.jpg" alt="XPath Result" title="xindice11" width="300" height="73" class="size-medium wp-image-199" /></a><p class="wp-caption-text">XPath Result</p></div><br />
finally you achieved the mission of updating a XML Database and showing the XPath Result using java and Xindice Database, you can now create more complex application based on XML database .
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.fouad-saidy.com/archives/26/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Step By Step Create Simple Calculator using Eclipse Galileo &amp;  EJB 3.0</title>
		<link>http://www.fouad-saidy.com/archives/12</link>
		<comments>http://www.fouad-saidy.com/archives/12#comments</comments>
		<pubDate>Sat, 30 Jan 2010 12:41:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[EJB]]></category>
		<category><![CDATA[JEE]]></category>

		<guid isPermaLink="false">http://fouad-saidy.freehostia.com/?p=12</guid>
		<description><![CDATA[



Remark:

I received many emails that talk about the error of  &#8220;Firstcalc not bound&#8221;  the problem that if you didn&#8217;t referenced the EJB project in the web application your server can not know the calcImpl class for this reason it shows this error.
 To resolve this error just try to remove @Stateless(mappedName = &#8220;Firstcalc&#8221;)  <a href="http://www.fouad-saidy.com/archives/12" class="more-link">More &#62;</a><p><a href="http://sharethis.com/item?&#038;wp=2.8.2&#38;publisher=c52c2557-5007-4da4-b176-d174646fb516&#38;title=Step+By+Step+Create+Simple+Calculator+using+Eclipse+Galileo+%26%23038%3B++EJB+3.0&#38;url=http%3A%2F%2Fwww.fouad-saidy.com%2Farchives%2F12">ShareThis</a></p>]]></description>
			<content:encoded><![CDATA[<p><span style="font-family: monospace; font-size: small;"><span class="Apple-style-span" style="font-size: 12px; line-height: 15px; white-space: pre-wrap;"><span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: medium; line-height: normal; white-space: normal;"></span></span></span><br />
<span style="font-family: monospace; font-size: small;"></span><br />
<span style="font-family: monospace; font-size: small;">
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<h2>Remark:</h2>
<p><span style="font-family: monospace;"><br />
I received many emails that talk about the error of <font color='red'> &#8220;Firstcalc not bound&#8221; </font> the problem that if you didn&#8217;t referenced the EJB project in the web application your server can not know the calcImpl class for this reason it shows this error.<br />
 To resolve this error just try to remove @Stateless(mappedName = &#8220;Firstcalc&#8221;) and replace it by @stateless,in the naming function in the servlet replace calc cl = (calc) ctx.lookup(&#8221;Firstcalc&#8221;); by  cl=(calc) ctx.lookup(&#8221;calcImpl/local&#8221;);<br />
I used the bounding without a mapped name of the calcImpl class, it&#8217;s Work correctly(tested with jboss server).<br />
</span></p>
<p>This tutorial is available in pdf book : <a href="http://www.scribd.com/doc/25396096/Step-By-Step-Create-Simple-Calculator-using-Eclipse-Galileo-EJB-3-0" style="display: inline !important; font-family: Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; margin-bottom: 6px; margin-left: auto; margin-right: auto; margin-top: 12px; text-decoration: underline;" title="View Step By Step Create Simple Calculator using Eclipse Galileo &amp;amp; EJB 3.0 on Scribd">Step By Step Create Simple Calculator using Eclipse Galileo &amp; EJB 3.0</a></div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
</div>
<p></span><br />
<span class="Apple-style-span" style="line-height: 15px; white-space: pre-wrap;"><span class="Apple-style-span" style="font-size: small;"><span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">We will use in this tutorial:</span></span></span></p>
<ul>
<li><span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"><a href="http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/SR1/eclipse-jee-galileo-SR1-win32.zip">Eclipse Galileo IDE</a> </span></span></li>
<li><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Arial; font-size: 13px; white-space: pre;"><a href="http://sourceforge.net/projects/jboss/files/JBoss/JBoss-5.1.0.GA/">JBoss-5.1.0.GA</a></span></li>
</ul>
<div>
<span style="font-family: monospace; font-size: 12px; line-height: 15px; white-space: pre-wrap;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">we will create an application in the server side based on EJB 3.0, and an author web client application</span></span> </div>
<div>
<ol>
<li><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; color: #3d85c6; font-family: Arial; font-size: 13px; font-weight: bold; white-space: pre;">Server Application Using EJB:</span></li>
</ol>
<div>
<ul>
<li><span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"><b><span style="color: #666666;">Configuration JBoss Server:</span></b></span></span></li>
</ul>
</div>
</div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"></span></span></div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">The second step is to configuarate the Jboss server in Eclipse Galieo IDE:</span></span> </div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">in Eclipse Menu choose Window&#8211;&gt; Preferences, then choose<br />
Server &#8211;&gt; Runtime Environments.</span></span> </div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"></span></span></div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">click add Button then choose JBoss&#8211;&gt; JBoss v5.0 and check&#8221; <b>Create a new local server</b>&#8221; </span></span></div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/_SIQbfFVpNY0/S1LJB3YeWHI/AAAAAAAAAD0/P_3v7dnny74/s1600-h/jboss.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://2.bp.blogspot.com/_SIQbfFVpNY0/S1LJB3YeWHI/AAAAAAAAAD0/P_3v7dnny74/s400/jboss.jpg" /></a> </div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"></span></span></div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">In Application Server Directory select the JBoss Server&nbsp;directory,<span style="color: red;"><br />
not the Content of the directory!</span> :</span></span> </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/_SIQbfFVpNY0/S1LJ5IuQ_WI/AAAAAAAAAD8/lwFHvEfqGLU/s1600-h/Jboss1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://1.bp.blogspot.com/_SIQbfFVpNY0/S1LJ5IuQ_WI/AAAAAAAAAD8/lwFHvEfqGLU/s400/Jboss1.jpg" /></a> </div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"></span></span></div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">you added the Jboss Server to Eclipse , now let&#8217;s add the Jboss Server<br />
to this section:</span></span> </div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">select the Server section clik and choose new-&gt;Server then next next<br />
until finish</span></span> </div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/_SIQbfFVpNY0/S1LL4XY0DQI/AAAAAAAAAEM/sMQM9pz_aXg/s1600-h/jboss2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://2.bp.blogspot.com/_SIQbfFVpNY0/S1LL4XY0DQI/AAAAAAAAAEM/sMQM9pz_aXg/s640/jboss2.jpg" /></a> </div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">the server appears like this in Server section:</span></span> </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/_SIQbfFVpNY0/S1LOkf8tQII/AAAAAAAAAEc/9ptHjspV6DA/s1600-h/jboss4.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://3.bp.blogspot.com/_SIQbfFVpNY0/S1LOkf8tQII/AAAAAAAAAEc/9ptHjspV6DA/s400/jboss4.jpg" /></a> </div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"></span></span></div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"></span></span></div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">Now we will verify that Jdk is the default installed JRE&#8217;s :</span></span> </div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">select Window&#8211;&gt;Preferences in this windows select Java&#8211;&gt; Installed JREs<br />
then if jdk is not checked check it ,or add it if it doesn&#8217;t exist:</span></span> </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/_SIQbfFVpNY0/S1LNvu9mrSI/AAAAAAAAAEU/rJVrY1EEpz4/s1600-h/Jboss3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://1.bp.blogspot.com/_SIQbfFVpNY0/S1LNvu9mrSI/AAAAAAAAAEU/rJVrY1EEpz4/s400/Jboss3.jpg" /></a> </div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">we finished configuration step let&#8217;s move now to programming an<br />
EJB Application.</span></span> </div>
<div style="text-align: left;">
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"></span></span></div>
<div style="text-align: left;">
<ul>
<li><span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"><b><span style="color: #666666;">EJB Application</span></b>:</span></span></li>
</ul>
<div>
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">in this application we will create :</span></span> </div>
<div>
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">Remote Interface <b>calc</b>,</span></span> </div>
<div>
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">Class <b>calcImpl</b> which implements calc.</span></span> </div>
<div>
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">select File&#8211;&gt;New&#8211;&gt; Other.. then create EJB Project :</span></span> </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/_SIQbfFVpNY0/S1LRbwc41qI/AAAAAAAAAEk/qU8TT6j_cs0/s1600-h/jboss5.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://4.bp.blogspot.com/_SIQbfFVpNY0/S1LRbwc41qI/AAAAAAAAAEk/qU8TT6j_cs0/s400/jboss5.jpg" /></a> </div>
<div class="separator" style="clear: both; text-align: left;">
specify the name of the project for example <b>SimpleCalculator</b>&nbsp;, and choose the JBoss v5 in target field: </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/_SIQbfFVpNY0/S1LSUj1bEPI/AAAAAAAAAEs/vAY3rIT05Os/s1600-h/jboss6.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://2.bp.blogspot.com/_SIQbfFVpNY0/S1LSUj1bEPI/AAAAAAAAAEs/vAY3rIT05Os/s400/jboss6.jpg" /></a> </div>
<div>
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">now we created a simple ejb project ,we will create source code in ejbModule directory :</span></span> </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/_SIQbfFVpNY0/S1LTomPxL_I/AAAAAAAAAE0/2skblNP_y7M/s1600-h/Jboss7.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://4.bp.blogspot.com/_SIQbfFVpNY0/S1LTomPxL_I/AAAAAAAAAE0/2skblNP_y7M/s400/Jboss7.jpg" /></a> </div>
<div>
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">we finished creating EJB project, create the interface calc with package first :</span></span> </div>
<div>
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/_SIQbfFVpNY0/S1LUfOtHwdI/AAAAAAAAAE8/C0mfwdUaBb0/s1600-h/jboss8.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://4.bp.blogspot.com/_SIQbfFVpNY0/S1LUfOtHwdI/AAAAAAAAAE8/C0mfwdUaBb0/s320/jboss8.jpg" /></a> </div>
<div>
<span style="font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;">add this code to your calc interface:</span></span> </div>
<div>
<b><span style="color: #38761d;">package ejb;</span></b> </div>
<div>
<b><span style="color: #38761d;">import javax.ejb.Local;</span></b> </div>
<div>
<b><span style="color: #38761d;"></span></b></div>
<div>
<b><span style="color: #38761d;">@Local</span></b> </div>
<div>
<b><span style="color: #38761d;">public interface calc {</span></b> </div>
<div>
<span style="white-space: pre;"><b><span style="color: #38761d;"></span></b></span><b><span style="color: #38761d;">public float sum(float a,float b);</span></b> </div>
<div>
<span style="white-space: pre;"><b><span style="color: #38761d;"></span></b></span><b><span style="color: #38761d;">public float mult(float a,float b);</span></b> </div>
<div>
<span style="white-space: pre;"><b><span style="color: #38761d;"></span></b></span><b><span style="color: #38761d;">public float minus(float a,float b);</span></b> </div>
<div>
<b><span style="color: #38761d;">public float div(float a,float b);</span></b> </div>
<div>
<b><span style="color: #38761d;">}</span></b> </div>
<div>
next step is to create calcImpl with the same way dont forgit to specify the same package (ejb), and add this code to class: </div>
<div>
<span style="color: #6aa84f;"><span style="color: #38761d;"><b>package ejb; import javax.ejb.Stateless;&nbsp;</b></span></span><br />
<span style="color: #6aa84f;"><span style="color: #38761d;"><b>@Stateless(mappedName=&#8221;Firstcalc&#8221;)&nbsp;</b></span></span></p>
<p><span style="color: #6aa84f;"><span style="color: #38761d;"><b>public class calcImpl implements calc { </b></span></span><br />
<span style="color: #6aa84f;"><span style="color: #38761d;"><b>public float sum(float a,float b) </b></span></span><br />
<span style="color: #6aa84f;"><span style="color: #38761d;"><b>{ return a+b; } </b></span></span><br />
<span style="color: #6aa84f;"><span style="color: #38761d;"><b>public float mult(float a,float b) </b></span></span><br />
<span style="color: #6aa84f;"><span style="color: #38761d;"><b>{ return a*b; } </b></span></span><br />
<span style="color: #6aa84f;"><span style="color: #38761d;"><b>public float minus(float a,float b) </b></span></span><br />
<span style="color: #6aa84f;"><span style="color: #38761d;"><b>{ return a-b; } </b></span></span><br />
<span style="color: #6aa84f;"><span style="color: #38761d;"><b>public float div(float a,float b) { </b></span></span><br />
<span style="color: #6aa84f;"><span style="color: #38761d;"><b>try { </b></span></span><br />
<span style="color: #6aa84f;"><span style="color: #38761d;"><b>return a/b; </b></span></span><br />
<span style="color: #6aa84f;"><span style="color: #38761d;"><b>}catch(Exception e){ </b></span></span><br />
<span style="color: #6aa84f;"><span style="color: #38761d;"><b>System.out.println(&#8221;Error:devision by 0!!&#8221;); </b></span></span><br />
<span style="color: #6aa84f;"><span style="color: #38761d;"><b>return 0; &nbsp;</b></span></span><br />
<span style="color: #6aa84f;"><span style="color: #38761d;"><b>} </b></span></span><br />
<span style="color: #6aa84f;"><span style="color: #38761d;"><b>}&nbsp;</b></span></span><br />
<span style="color: #6aa84f;"><span style="color: #38761d;"><b>}</b></span> </span></div>
<div>
now we finished EJB Application let&#8217;s move to The Web Client Application. </p>
<ol>
<li value="2"><span style="color: #3d85c6;"><b>Web Client Application:</b></span></li>
</ol>
<div>
<b>select File&#8211;&gt;New&#8211;&gt;Dynamic Web Project , it&#8217;s name: SimpleCalculatorWeb</b> </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/_SIQbfFVpNY0/S1LbTUH4VzI/AAAAAAAAAFE/GnAm3r24_9U/s1600-h/jboss9.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://2.bp.blogspot.com/_SIQbfFVpNY0/S1LbTUH4VzI/AAAAAAAAAFE/GnAm3r24_9U/s400/jboss9.jpg" /></a> </div>
<div>
add a jsp page called index to the <b>WebContent</b> directory : </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/_SIQbfFVpNY0/S1LhDcxvePI/AAAAAAAAAFc/oOE8z0OtaX8/s1600-h/jboss12.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://1.bp.blogspot.com/_SIQbfFVpNY0/S1LhDcxvePI/AAAAAAAAAFc/oOE8z0OtaX8/s320/jboss12.jpg" /></a> </div>
<div>
add this form to index.jsp:<br />
<span style="color: #38761d;"><b><br />
</b></span><br />
<span style="color: #38761d;"><b>&lt;h2&gt; &lt;b&gt; Hello World To The Simple Calculator &lt;/b&gt; &lt;/h2&gt;&nbsp;</b></span><br />
<span style="color: #38761d;"><b>&lt;% float a=2,b=1; &nbsp;</b></span><br />
<span style="color: #38761d;"><b>if (request.getAttribute(&#8221;a&#8221;)!=null)&nbsp;</b></span><br />
<span style="color: #38761d;"><b>a=Float.parseFloat(request.getAttribute(&#8221;a&#8221;).toString()); &nbsp;</b></span><br />
<span style="color: #38761d;"><b>if( request.getAttribute(&#8221;b&#8221;)!=null) &nbsp;</b></span><br />
<span style="color: #38761d;"><b>b=Float.parseFloat(request.getAttribute(&#8221;b&#8221;).toString()); %&gt;</b></span><br />
<span style="color: #38761d;"><b>&lt;form method=&#8221;post&#8221; action=&#8221;calcServlet&#8221;&gt;&nbsp;</b></span><br />
<span style="color: #38761d;"><b>&lt;b&gt;Number 1:&lt;/b&gt;&lt;input type=&#8217;text&#8217; name=&#8217;n1&#8242; value=&#8221;&lt;%=a%&gt;&#8221; /&gt; &lt;br/&gt;&nbsp;</b></span><br />
<span style="color: #38761d;"><b>&lt;b&gt;Number 2:&lt;/b&gt;&lt;input type=&#8217;text&#8217; name=&#8217;n2&#8242; value=&#8221;&lt;%=b%&gt;&#8221; /&gt; &lt;br/&gt;&nbsp;</b></span><br />
<span style="color: #38761d;"><b>&lt;u&gt;&lt;b&gt;Options:&lt;/b&gt;&lt;/u&gt; &lt;br/&gt;</b></span><br />
<span style="color: #38761d;"><b>&lt;ul&gt; &nbsp;</b></span><br />
<span style="color: #38761d;"><b>&lt;li&gt;&lt;b&gt;+&lt;/b&gt;&lt;input type=&#8217;radio&#8217; name=&#8221;oper&#8221; value=&#8217;+&#8217; checked /&gt;&lt;/li&gt; &nbsp;</b></span><br />
<span style="color: #38761d;"><b>&lt;li&gt;&lt;b&gt;&amp;nbsp;-&lt;/b&gt;&lt;input type=&#8217;radio&#8217; name=&#8221;oper&#8221; value=&#8217;-&#8217; /&gt;&lt;/li&gt;</b></span><br />
<span style="color: #38761d;"><b>&lt;li&gt;&lt;b&gt;*&lt;/b&gt;&lt;input type=&#8217;radio&#8217; name=&#8221;oper&#8221; value=&#8217;*&#8217; /&gt;&lt;/li&gt;&nbsp;</b></span><br />
<span style="color: #38761d;"><b>&lt;li&gt;&amp;nbsp; &lt;b&gt;/&lt;/b&gt;&lt;input type=&#8217;radio&#8217; name=&#8221;oper&#8221; value=&#8217;/&#8217; /&gt;&lt;/li&gt; &lt;/ul&gt;&nbsp;</b></span><br />
<span style="color: #38761d;"><b>&lt;b&gt;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&lt;/b&gt; &lt;br/&gt;&nbsp;</b></span><br />
<span style="color: #38761d;"><b>&lt;input type=&#8221;submit&#8221; value=&#8221;Executer&#8221; /&gt; &lt;/form&gt;</b></span><br />
<span style="color: #38761d;"><b>&lt;font color=&#8217;blue&#8217;&gt;&lt;b&gt;Result is: &lt;/b&gt; &lt;%=session.getAttribute(&#8221;result&#8221;)%&gt; &lt;/font&gt; &lt;br/&gt;</b></span><br />
<span style="color: #38761d;"><b>&lt;font color=&#8217;red&#8217; &gt;Error: &lt;%=session.getAttribute(&#8221;error&#8221;)%&gt;&lt;/font&gt;</b></span></p>
</div>
<div>
</div>
<div>
</div>
<div>
now create a <b>calServlet</b> with <b>web</b> package in the<strong> JavaResources :src</strong> directory : </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/_SIQbfFVpNY0/S1LcozaU1aI/AAAAAAAAAFM/UR3Ffldk_m4/s1600-h/jboss10.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://4.bp.blogspot.com/_SIQbfFVpNY0/S1LcozaU1aI/AAAAAAAAAFM/UR3Ffldk_m4/s400/jboss10.jpg" /></a> </div>
<div>
servlet is created like this: </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/_SIQbfFVpNY0/S1LdX21jqtI/AAAAAAAAAFU/HH3VUKJpp98/s1600-h/jboss11.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://3.bp.blogspot.com/_SIQbfFVpNY0/S1LdX21jqtI/AAAAAAAAAFU/HH3VUKJpp98/s320/jboss11.jpg" /></a> </div>
<div>
add those import to your servlet class: </div>
<div>
<b><span style="color: #38761d;">import java.io.IOException;&nbsp;</span></b><br />
<b><span style="color: #38761d;">import javax.naming.*;&nbsp;</span></b><br />
<b><span style="color: #38761d;">import javax.servlet.*;</span></b><br />
<b><span style="color: #38761d;">import javax.servlet.*;&nbsp;</span></b><br />
<b><span style="color: #38761d;">import javax.servlet.http.*;</span></b><br />
<span style="color: #38761d;"><b><br />
</b></span></div>
<div>
</div>
<div>
copy this code to the doGet function : </div>
<div>
<span style="color: #38761d;"><b><br />
</b></span><br />
<b><span style="color: #38761d;">HttpSession session=request.getSession(true);&nbsp;</span></b><br />
<b><span style="color: #38761d;"></span></b><b><span style="color: #38761d;">RequestDispatcher rd=this.getServletContext().getRequestDispatcher(&#8221;/index.jsp&#8221;); &nbsp;</span></b></p>
<p><b><span style="color: #38761d;"></span></b><b><span style="color: #38761d;">float a=Float.parseFloat(request.getParameter(&#8221;n1&#8243;)); &nbsp;</span></b> <b><span style="color: #38761d;">&nbsp;</span></b><br />
<b><span style="color: #38761d;">float b=Float.parseFloat(request.getParameter(&#8221;n2&#8243;)); &nbsp;</span></b> <b><span style="color: #38761d;">&nbsp;</span></b><br />
<b><span style="color: #38761d;">char oper=request.getParameter(&#8221;oper&#8221;).charAt(0); </span></b><b><span style="color: #38761d;">&nbsp;</span></b><br />
<b><span style="color: #38761d;">float result=0; </span></b><br />
<b><span style="color: #38761d;"></span></b><b><span style="color: #38761d;">try { </span></b><b><span style="color: #38761d;"></span></b><br />
<b><span style="color: #38761d;">Context ctx=new InitialContext(); </span></b><b><span style="color: #38761d;"></span></b><br />
<span style="color: #38761d;"><b>// call the calcImpl class of the SimpleCalculator EJB with the mappedName </b></span><br />
<b><span style="color: #38761d;">calc cl=(calc) ctx.lookup(&#8221;Firstcalc&#8221;); </span></b><b><span style="color: #38761d;">&nbsp;</span></b><br />
<b><span style="color: #38761d;">switch(oper) </span></b><b><span style="color: #38761d;">&nbsp;</span></b><br />
<b><span style="color: #38761d;">{ </span></b><br />
<b><span style="color: #38761d;">case &#8216;+&#8217;: result=cl.sum(a, b); </span></b><b><span style="color: #38761d;">break; </span></b><b><span style="color: #38761d;">&nbsp;</span></b><br />
<b><span style="color: #38761d;">case &#8216;-&#8217;: result =cl.minus(a, b); </span></b><b><span style="color: #38761d;">break; </span></b><br />
<b><span style="color: #38761d;"></span></b><b><span style="color: #38761d;">case &#8216;*&#8217;: result =cl.mult(a, b); </span></b><b><span style="color: #38761d;">break;</span></b> </div>
<div>
<span style="color: #38761d; font-weight: bold;">case &#8216;/&#8217;: result =cl.div(a, b);</span> <b><span style="color: #38761d;">break; </span></b><br />
<b><span style="color: #38761d;">} </span></b><br />
<b><span style="color: #38761d;">session.setAttribute(&#8221;result&#8221;,result); request.setAttribute(&#8221;a&#8221;, a); request.setAttribute(&#8221;b&#8221;, b); </span></b><br />
<b><span style="color: #38761d;">}catch(NamingException e){ </span></b><br />
<b><span style="color: #38761d;">session.setAttribute(&#8221;erreur: &#8220;,e.getMessage()); </span></b><br />
<b><span style="color: #38761d;">} </span></b><br />
<b><span style="color: #38761d;">rd.forward(request,response);</span></b> </div>
<ol></ol>
</div>
<div>
</div>
<div>
</div>
</div>
<p>to let the the web client application to know the calc interface we must configure the build path of the project in adding the first project&nbsp;<span style="font-weight: bold;">SimpleCalculator :</span></p>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/_SIQbfFVpNY0/S1Lmra0NDiI/AAAAAAAAAFk/yWVmq3JC38U/s1600-h/jboss13.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://3.bp.blogspot.com/_SIQbfFVpNY0/S1Lmra0NDiI/AAAAAAAAAFk/yWVmq3JC38U/s640/jboss13.jpg" /></a></div>
<p>in the project section click add &nbsp;and select<b> SimpleCalculator:&nbsp;</b></p>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/_SIQbfFVpNY0/S1Ln4qrIU1I/AAAAAAAAAFs/fXXgxlCe-c0/s1600-h/jboss14.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://3.bp.blogspot.com/_SIQbfFVpNY0/S1Ln4qrIU1I/AAAAAAAAAFs/fXXgxlCe-c0/s400/jboss14.jpg" /></a></div>
<p>now add this import to your servlet class :<br />
<b><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; color: #38761d; font-family: Arial; font-size: 13px; white-space: pre;">import ejb.calc;</span></b><br />
<span style="color: #38761d; font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"><b><br />
</b></span></span><br />
<span style="color: #38761d; font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"><b>let&#8217;s deploy the two project ,firstly play the JBoss Server in Server section:</b></span></span></p>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/_SIQbfFVpNY0/S1Lr0ozzJlI/AAAAAAAAAF0/ZHGHAEPCaL8/s1600-h/jboss15.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://2.bp.blogspot.com/_SIQbfFVpNY0/S1Lr0ozzJlI/AAAAAAAAAF0/ZHGHAEPCaL8/s320/jboss15.jpg" /></a></div>
<p><span style="color: #38761d; font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"><b>deploying the EJB Project :</b></span></span></p>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/_SIQbfFVpNY0/S1LsZinxh2I/AAAAAAAAAF8/AGGUDZo4ha8/s1600-h/jboss16.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://4.bp.blogspot.com/_SIQbfFVpNY0/S1LsZinxh2I/AAAAAAAAAF8/AGGUDZo4ha8/s400/jboss16.jpg" /></a></div>
<p><span style="color: #38761d; font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"><b><br />
</b></span></span><br />
<span style="color: #38761d; font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"><b>with the same way deploy SimpleCalculatorWeb:</b></span></span></p>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/_SIQbfFVpNY0/S1MMUjVo5_I/AAAAAAAAAGE/tXh0s1AqBUI/s1600-h/Jboss17.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox-12"><img border="0" src="http://4.bp.blogspot.com/_SIQbfFVpNY0/S1MMUjVo5_I/AAAAAAAAAGE/tXh0s1AqBUI/s640/Jboss17.jpg" /></a></div>
<p><span style="color: #38761d; font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"><b>if you have any remarks or questions dont hesitate to post it.<br />
</b></span></span><br />
<span style="color: #38761d; font-family: Arial; font-size: small;"><span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 13px; white-space: pre;"><b><br />
</b></span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fouad-saidy.com/archives/12/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

