当前位置:网站首页>JSP basic grammar experiment
JSP basic grammar experiment
2022-07-19 01:07:00 【Junior Hyena】
example 3.6 Handling of page exceptions .
establish example3_6.jsp page , Use page Instructions
Of errorPage Property specifies the page to which the page will turn when an exception occurs . This program performs division
count , Such as fruit except Count by 0 , take Meeting Throw Out One individual Count learn shipment count different often , from errorPage="
example3_6_error.jsp" It can be seen that , Program designation example3_6_error.jsp Handle it
abnormal . To create a example3_6_error.jsp page , Use page The directive isErrorPage Belong to
Property is specified as error page , This page can use exception Exception object handling error messages .
example3_6.jsp The specific code is as follows :
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" errorPage="example3_6_error.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>example3_6.jsp</title>
</head>
<body>
<%
int x1=5;
int x2=0;
int x3=x1/x2;
out .print (x3);
%>
</body>
</html>
example3_6_error.jsp The specific code is as follows :
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" isErrorPage="true"%>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>example3_6error.jsp</title>
</head>
<body>
There is an error , Error is as follows :<br/>
<hr>
<%=exception.getMessage() %>
</body>
</html>
example 3.7
To write example3_7.jsp page , Page shows “ Please enter two integers , Click Submit
Button to find the square difference between these two integers ”. Write another example3_7_input.jsp page , It is obvious
Show form , Enter two integers , Click the submit button to display the square difference between the two numbers , The effect is as follows
As shown in the figure . Ask for in example3_7.jsp The page contains example3_7_input.jsp.
example3_7.jsp The specific code is as follows :
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>example3_7.jsp</title>
</head>
<body>
<p> Please enter two integers , Click the submit button to find the square difference between the two numbers </p>
<%@ include file="example3_7input.jsp" %>
</body>
</html>
example3_7_input.jsp The specific code is as follows :
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>example3_7_inpute.jsp</title>
</head>
<body>
<form action="" method="post">
Integers 1: <input type="text" name="n1"/>
<br/><br/>
Integers 2: <input type="text" name="n2"/>
<br/><br/><input type="submit" value=" Submit "/>
</form>
<%
String n1=request.getParameter("n1");
String n2=request.getParameter("n2");
if(n1!=null&n2!=null){
int a,b;
try{
a=Integer.parseInt(n1);
b=Integer.parseInt(n2);
%>
<p> The square difference between the two integers you enter is :<%=a*a-b*b %></p>
<%
}
catch(Exception e){
out.print(" Please enter two integers !");
}
}
%>
</body>
</html>
边栏推荐
猜你喜欢
随机推荐
在mysql数据库插入中文值出现的乱码解决
See the application of comparative learning in recommendation from 22 top meetings
从编译器对指令集的要求看API设计原则
1.两数之和
virtualbox 菜单栏控制
Application of optimistic lock and pessimistic lock in kubernetes
Unity 2D游戏教程
Vite3.0 release
必备基础:加签验签
一小时搭建属于属于自己的博客系统网站
【著色器實現Wave效果_Shader效果第一篇】
从22顶会看对比学习在推荐的应用
Redis命令
Uva11362 phone list solution
【MD5】快速实现MD5加密解密(盐值)
PySide2嵌入外部程序
工具版本号
Briefly talk about two interview questions encountered recently
[Clickhouse] calculation of weeks
MySQL - Multi version concurrency control (mvcc)






![(manual) [sqli-labs62-65] limit injection times: blind injection](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)


