1、判断用户名是否为空,空则显示提示信息
(1)编写index.jsp页面
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <form name="form1" method="post" action="deal.jsp"> 用户名:<input name="user" type="text" id="user"> <br><br> 密 码:<input name="pwd" type="password" id="pwd"> <br><br><br> <input type="submit" name="Submit" value="登录"> <input type="reset" name="Submit2" value="重置"> </form> </body> </html>
(2)编写deal.jsp页面
<body> ${empty param.user?"请输入用户名":"" } ${empty param.pwd?"请输入密码":"欢迎访问! " } <br> <a href="index.jsp">返回</a> </body>
2、显示客户使用的浏览器
index.jsp页面的代码如下:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> 客户端使用的浏览器为:<br> ${header["user-agent"]} </body>
</html>