problem Creating Calculator with java and jsp
this is my java coding
Code:
package user;
/**
* Created by abansari
* User: Administrator
* Date: Nov 30, 2009
* Time: 2:59:48 PM
*/
public class UserData {
private long value1;
private long value2;
private char op;
private long result;
UserData()
{
value1 = 0;
value2 = 0;
op = '+';
result = 0;
}
void setFirstValue(long newValue)
{
value1 = value1 + newValue;
}
void setSecValue(long newValue)
{
value2 = value2 + newValue;
}
long getFirstValue()
{
return value1;
}
long getSecValue()
{
return value2;
}
}
this is my jsp page coding.
Code:
<%@ page import="user.UserData" %>
<%--
Created by IntelliJ IDEA.
User: abansari
Date: Dec 5, 2009
Time: 2:39:02 PM
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Calculator</title>
</head>
<body>
<%
// these lines for test purpose only //
long value1;
long value2;
char op;
long result;
value1 = 1;
value2 = 2;
result = value1 + value2;
// test purpose lines end //
%>
<table border="1px">
<form name="Calc" method="post" action="">
<tr>
<td colspan="4">
<input type="text" name="textbox" value="<%=result%>">
</td>
</tr>
<tr>
<td>
<input type="button" name="1" value="1" onclick="var value1 = this.value">
</td>
<td>
<input type="button" name="2" value="2">
</td>
<td>
<input type="button" name="3" value="3">
</td>
<td>
<input type="button" name="divide" value="/">
</td>
</tr>
<tr>
<td>
<input type="button" name="4" value="4">
</td>
<td>
<input type="button" name="5" value="5">
</td>
<td>
<input type="button" name="6" value="6">
</td>
<td>
<input type="button" name="minus" value="-">
</td>
</tr>
<tr>
<td>
<input type="button" name="7" value="7">
</td>
<td>
<input type="button" name="8" value="8">
</td>
<td>
<input type="button" name="9" value="9">
</td>
<td>
<input type="button" name="multiply" value="*">
</td>
</tr>
<tr>
<td>
<input type="button" name="dot" value=".">
</td>
<td>
<input type="button" name="0" value="0">
</td>
<td>
<input type="submit" name="equal" value="=">
</td>
<td>
<input type="button" name="plus" value="+">
</td>
</tr>
</form>
</table>
</body>
</html>
my problem is now how to call java class is in jsp file?
thanks