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

JSP 04课 (2)

时间:2020-03-28 17:47:37      阅读:77      评论:0      收藏:0      [点我收藏+]

标签:contex   java   serve   uname   art   coding   password   desc   imp   

技术图片技术图片

<%@ 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课 (2)

标签:contex   java   serve   uname   art   coding   password   desc   imp   

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

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