zoukankan      html  css  js  c++  java
  • JAVA EE JSP_EL

    http://www.javapassion.com/j2ee/

    http://hi.baidu.com/livinggame/blog/item/0118eceffebbd437adafd50d.html

    <%@   page isELIgnored="true"%>

    表示是否禁用EL语言,TRUE表示禁止.FALSE表示不禁止.JSP2.0中默认的启用EL语言.

    登陆用户名和密码后,若密码错误则保留用户名.

    login.java

    package com.lindows.action;
    
    import java.io.IOException;
    import java.io.PrintWriter;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    public class login extends HttpServlet {
    
    
    
    	/**
    	 * The doPost method of the servlet. <br>
    	 *
    	 * This method is called when a form has its tag value method equals to post.
    	 * 
    	 * @param request the request send by the client to the server
    	 * @param response the response send by the server to the client
    	 * @throws ServletException if an error occurred
    	 * @throws IOException if an error occurred
    	 */
    	public void doPost(HttpServletRequest request, HttpServletResponse response)
    			throws ServletException, IOException {
    		//String name = request.getAttribute("uname").toString();
    		String nameString = (String)request.getParameter("uname");
    		System.out.println(nameString);
    		//request.setAttribute("name", name);
    	}
    
    
    
    }
    
     

    web.xml

    	<servlet>
    		<servlet-name>login</servlet-name>
    		<servlet-class>com.lindows.action.login</servlet-class>
    	</servlet>
    	<servlet-mapping>
    		<servlet-name>login</servlet-name>
    		<url-pattern>/login</url-pattern>
    	</servlet-mapping>
     

    login.jsp

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%@ page isELIgnored="false" %>
    <%
    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">
    	-->
        <script>
        	function funsub()
        	{
        		alert(document.getElementById("uname").value);
        		document.fm.action="<%=request.getContextPath()%>/login";
        		document.fm.submit();
        	}
        </script>
      </head>
      
      <body>
    	<form method=get action="/register.jsp"> 
    		username:<input type="text" value="username">
    	</form>
        <form name="fm" method="post">
        <input type="text" name="uname" >
        <input type="button" value="ok" οnclick="funsub()">
        </form>
      </body>
    </html>
    
     

    end

  • 相关阅读:
    数据库回滚解决删除数据库出错
    教大家支付宝抢红包
    MySql 连接字符串
    搭建Git服务器
    队列的顺序存储结构
    栈的应用---递归
    栈的链式存储结构及应用(C、Java代码)
    栈的顺序存储结构及应用(C、Java代码)
    静态链表、循环链表、双向链表(C代码实现)
    线性表的链式存储结构(Java代码实现)
  • 原文地址:https://www.cnblogs.com/lindows/p/14390498.html
Copyright © 2011-2022 走看看