Hello, i have to do a project that presents a form with 3
text fields like this
type 2 numbers and then the symbol(+,/,*,-) and do the
appropriate action.
I am using Tomcat 6.0.
I've done so far:


<form method="post" action="simple.jsp">
Number_1<br> <input type="text" name="value1"><p>
Number_2<br> <input type="text" name="value2"><p>
Symbol<br> <input type="text" name="value3"><br>
<input type="submit" value="Submit">


<jsp:useBean id="SimpleBean" class="test.SimpleBean" scope="page">
<jsp:setProperty name="SimpleBean" property="*"/>
<% SimpleBean.add(); %>


Sum = <jsp:getProperty name="SimpleBean" property="result"/> <br>

Symbol = <jsp:getProperty name="SimpleBean" property="symbol"/>



package test;

public class SimpleBean {
	private int value1;
	private int value2;
	private int result;
	private String value3;
	private String symbol;

	public void setValue1(int x){
		value1 = x;
	public void setValue2(int x){
		value2 = x;
	public void setValue3(String x){
		value3 = x;
	public int getResult(){
		return result;
	public String getSymbol(){
		return symbol;
	public void add(){
		result = value1+value2;


so far i didn't tried to check what the symbol is because i put
the program to print it and prints null.
Look: [img]http://i48.tinypic.com/otj5s1.jpg[/img]

i don't know what i'm doing wrong. :(
Please any help would be appreciated. :)

Edited by panagos: n/a

7 Years
Discussion Span
Last Post by panagos

remove private String Value3 and change setValue3 with code like this

public void setSymbol(String x){
    symbol = x;

Then rename

Symbol<br> <input type="text" name="value3"><br>

with this

Symbol<br> <input type="text" name="symbol"><br>

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)


i solved it like a week ago, but
thnx for the interest.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.