请给位高手帮忙:写JSP代码:实现如下功能,
1. 建立一个Web应用,在主页面实现登录见面,在其中输入用户名,密码,发送到登录验证页面,登录成功,显示成功提示,登录失败,显示失败页面。
2. 在登录成功之后,在成功页面中显示当前站点的被访问的次数,如果同一用户已经登录,多次刷新此页面,不重计数。
3. 在工程中增加一个页面,在页面中实现加减乘除的运算页面,并实现运算结果的计算显示功能。
三
1. 在成功页面中增加计数处理代码。
2. 实现加减乘除的运算页面;
3. 实现运算结果的计算显示功能。
追问:
能运行吗?谢谢 好想只是部分功能的代码
答案:MyJsp.jsp
<body>
<form action="yanzheng.jsp" method="get">
用户名:<input type="text" name="username"/>
密码: <input type="password" name="password"/>
<input type="submit" value="登录" />
</form>
</body>
yangzheng.jsp
<body>
<%
String username = request.getParameter("username");
String pwd = request.getParameter("password");
if("baidu".equals(username) && "123".equals(pwd)){
session.setAttribute("username",username);
request.getRequestDispatcher("success.jsp").forward(request,response);
}else{
request.getRequestDispatcher("error.jsp").forward(request,response);
}
%>
</body>
success.jsp
<body>
<%
Integer count = (Integer)application.getAttribute("count");
String username = (String)session.getAttribute("username");
if(count != null){
if(username != null && username.equals("baidu")){
count++;
application.setAttribute("count",count);
}
response.getWriter().print(application.getAttribute("count"));
}else{
count = 1;
application.setAttribute("count",count);
response.getWriter().print(application.getAttribute("count"));
}
%>
</body>
error.jsp
<body>
Sorry,Is Error!!<br>
</body>
上一个:谁有JSP档案管理系统的代码?
下一个:在家做JSP图书管理系统 代码和调试都好了 我该怎么把它教给老师 导入的图片会因换电脑问题图片显示不了吗