<%@ page language=“java” import=“java.util.*” pageEncoding=“UTF-8”%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"?/"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<title>My JSP 'SiziyunsuanGaoji.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<%! public class Calus{ int x; int y; int add(){ return x+y; } int sub(){ return x-y; } int mul(){ return x*y; } int div(){ return x/y; } } %> + - * / <% Calus c=new Calus(); if(request.getParameter("one")!=null){ c.x=Integer.parseInt(request.getParameter("one")); } if(request.getParameter("two")!=null){ c.y=Integer.parseInt(request.getParameter("two")); }
String s=request.getParameter(“sel”);
%>
<%
if(“1”.equals(s)){
%>
<%=c.add() %>
<%}%>
<%
if(“2”.equals(s)){
%>
<%=c.sub() %>
<%}%>
<%
if(“3”.equals(s)){
%>
<%=c.mul() %>
<%}%>
<%
if(“4”.equals(s)){
%>
<%=c.div() %>
<%}%>