JSP implements a web calculator and jsp implements a calculator.
(1) The code for implementing the Web calculator in jsp is as follows: there are only two jsp pages.
MyCal. jsp is as follows:
<% @ Page language = "java" import = "java. util. * "pageEncoding =" UTF-8 "%> <% String path = request. getContextPath (); String basePath = request. getScheme () + ": //" + request. getServerName () + ":" + request. getServerPort () + path + "/"; %> <! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
MyResult. jsp is as follows:
<% @ Page language = "java" import = "java. util. * "pageEncoding =" UTF-8 "%> <% String path = request. getContextPath (); String basePath = request. getScheme () + ": //" + request. getServerName () + ":" + request. getServerPort () + path + "/"; %> <! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
(2) Although the process is simple, there are several points worth learning:
How to determine whether the input data is a number: use Math. round (form1.num1. value )! = Form1.num1. value to judge;
How to get the operation value: Set the flag implementation of the name attribute;
Compile a JSP page to implement a simple calculator (only one JSP page can be used)
Something simple. Jsp and js are all done. It can be written in addition, subtraction, multiplication, division, and js. I think more about LZ.
Implement a jsp page counter
To store counters, you must store databases or texts.