JSP implements the calculator function (web edition ),
The code for jsp implementation web page calculator 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. jspAs 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">
Although the process is simple, it is worth a few.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.
I hope this article will help you learn JSP programming.
Articles you may be interested in:
- Use jsp to call javabean to implement an ultra-simple web page calculator example
- A simple calculator Method Based on JSP