请给位高手帮忙:写JSP代码:实现如下功能,
发布网友
发布时间:2023-01-02 16:46
我来回答
共1个回答
热心网友
时间:2023-10-09 19:36
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("".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("")){
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>追问能运行吗?谢谢 好想只是部分功能的代码