hi

in jsp how do i add two numbers that has been inputed by user which is in a text box...


thank you

Recommended Answers

All 6 Replies

convert them both to a numerical data type and then add them together.
Very easy.

convert them both to a numerical data type and then add them together.
Very easy.

hi if i do it the way you said and add another text box for result. if a user enters two numbers would it show the result instantly.

thank you

hi

i mean i knw how to calculate and convert to int. But if put the total in a variable. then how would i retrive it in servlet and save it in the database?

thanks

you'd have to send it to the servlet, the servlet isn't going to know it's there to be saved unless someone tells it so.

you'd have to send it to the servlet, the servlet isn't going to know it's there to be saved unless someone tells it so.

how would i send it to servlet is it the action attribute.... or something else? because the variable total wouldnt be shown to users..

As a request attribute, or a session attribute, doesn't really matter.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.