JSP implements a web calculator and jsp implements a calculator.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.