JSP 04课
Posted naoguakerteng
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JSP 04课 相关的知识,希望对你有一定的参考价值。
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP ‘login.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"> --> </head> <body> <form action="doLogin.jsp" method="post"> <div align="center" style="background: url(images/Snap1.jpg);background-repeat:no-repeat;background-position-x:50%;height:500px"> <div style="margin-left:250px;margin-top:130px"> <p>用户名:</p><input type="text" name="uname" style="width:150px;height:30"><br> <p >密码:</p><input type="password" name="upwd" style="width:150px;height:30"><br> <br><input type="submit" name="LOGIN" value=" " style="background: url(images/login.gif);background-repeat:no-repeat;heigth:20px;width:110px" > </div> </div> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP ‘doLogin.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"> --> </head> <body> <% request.setCharacterEncoding("utf-8"); String name=request.getParameter("uname"); String pwd=request.getParameter("upwd"); if(name.equals("lucky")&&pwd.equals("123456")){ request.getRequestDispatcher("welcome.jsp").forward(request,response); }else{ request.getRequestDispatcher("login.jsp").forward(request,response); } %> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP ‘welcome.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"> --> </head> <body> <div align="center"> <p>你好!Lucky!</p> </div> </body> </html>
以上是关于JSP 04课 的主要内容,如果未能解决你的问题,请参考以下文章