码迷,mamicode.com
首页 > Web开发 > 详细

JSP 04课 (1)

时间:2020-03-28 16:29:20      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:pre   rpo   com   his   tle   sep   sheet   path   form   

技术图片

技术图片

<%@ 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">  
    <p>用户名:</p><input type="text" name="uname" style="width:150px;height:30"><br>
    <br>
    <p >密码:</p><input type="password" name="upwd" style="width:150px;height:30"><br>
  <br><input type="submit" name="LOGIN" value="登录" ><br>
    </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 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>
<%@ 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>

 

JSP 04课 (1)

标签:pre   rpo   com   his   tle   sep   sheet   path   form   

原文地址:https://www.cnblogs.com/naoguakerteng/p/12587840.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!