Calculator using ejb make enterprise java beans Java EE application
[Link]
Value=”${t1
<option value=""> select </option>
<option value="add" <c:if test="${operation == 'add'}"> selected </c:if>> Add </option>}”
[Link]
make session bean first by adding business method
calculator double parameter integer
[Link]
Insert code call enterprise bean newSessionBean add it
try {
int num1 = [Link](t1);
int num2 = [Link](t2);
result = [Link](num1, num2, operation);
if (result == null) {
error = "Invalid operation or divide by zero!";
} catch (NumberFormatException e) {
error = "Please enter valid numeric values.";
5 times [Link](“t1”, t1);
[Link]("[Link]").forward(request, response);
Registration form using jdbc
[Link]
After that make database create table connect java db start connections
Create table username password email country
[Link]
String u= [Link]("t1");
String p= [Link]("t2");
String e= [Link]("t3");
[Link]("Values:" +u+ ":" +p+ ":" +e);
String c
switch case
Connection con= [Link]("jdbc:derby://localhost:1527/emp" , "mydb", "mydb");
[Link]("<h1> connected </h1>");
Statement stmt= [Link]();
String sql="insert into EMPLOYEE_REG(Username, Password, Email, Country)values('"+u+"',
'"+p+"', '"+e+"', '"+c+"')";
[Link]("<h1> Query "+sql+" </h1>");
int res= [Link](sql);
[Link]("<h1> updated </h1>");
// [Link]("<h1>Servlet NewS ervlet at " + [Link]()+ "</h1>");
[Link]("</body>");
[Link]("</html>");
} catch(SQLException ex) {
[Link]([Link]()).log([Link], null, ex);
}
The data need to reflected In database
Wherever you will make sessionbean give package name
Currency converter Java EE Enterprise app
[Link]
Type=”radio” name=”type”
[Link]
public Double RupDol(double Rupees) {
return Rupees/65.65;
// Add business logic below. (Right-click in editor and choose
// "Insert Code > Add Business Method")
public Double DolRup(double Dollar) {
return Dollar*65.65;
after creating mthod RupDol and DolRup make changes evrywhere
[Link]
Insert code call enterprise bean newsessionbean
[Link]("<body>");
Double amt= [Link]([Link]("amt"));
String type= [Link]("type");
if("RupDol".equals(type))
double result= [Link](amt);
[Link]("<h1>" +amt+ "Rupees=" +result+ "dollar<h1>");
else if("DolRup".equals(type))
{
double result= [Link](amt);
[Link]("<h1>" +amt+ "Dollar=" +result+ "Rupees<h1>");
else {
[Link]("<h2> invalid conversion type</h2>");
//[Link]("<h1>Servlet NewServlet at " + [Link]() + "</h1>");
[Link]("</body>");
Session
Cookie
RequestDispatcher’
1st servlet
2nd servlet
[Link]("<body>");
[Link]("Welcome to the page");
[Link]("</body>");
[Link]("</html>");
4 jsps