1.求jsp登录源码 急急急急急急急急急急急
2.å¦ä½è¿ç¨JSPå¶ä½webQQ谢谢äºï¼å¤§ç¥å¸®å¿å
求jsp登录源码 急急急急急急急急急急急
登陆页面 index.jsp源码:
<%@ 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. Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>login</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="LoginServlet" method="post">
用户名:<input type="text" name="username" ><br>
密码:<input type="password" name="userpass"><br>
<input type="submit" value="登陆"> <input type="reset" value="取消">
</form>
</body>
</html>
-------------
LoginServlet.java 源码:
package servlet;
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 LoginServlet extends HttpServlet {
/
*** Constructor of the object.
*/
public LoginServlet() {
super();
}
/
*** Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/
*** The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @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 doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//获得jsp页面传输的参数
String username=request.getParameter("username");
String userpass=request.getParameter("userpass");
//判断
if(username.equals("user")&&userpass.equals("")){
response.sendRedirect("1.jsp");
}else if(username.equals("admin")&&userpass.equals("")){
response.sendRedirect("2.jsp");
}else{
response.sendRedirect("index.jsp");
}
}
/
*** 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 {
this.doGet(request, response);
}
/
*** Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
-------------
1.jsp:
<%@ 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. Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP '1.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>
This is 1.jsp <br>
</body>
</html>
-------------
2.jsp
<%@ 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. Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP '1.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>
This is 2.jsp <br>
</body>
</html>
å¦ä½è¿ç¨JSPå¶ä½webQQ谢谢äºï¼å¤§ç¥å¸®å¿å
è¿ä¸ªè¯´èµ·æ¥å¯å°±å¤§äºï¼æç»ä½ 讲讲è¿ç¨å°äºåªäºææ¯å§ï¼åµåµï¼æ¯ç«æ´ä¸ªç³»ç»è¿æ¯æ¯è¾å¤æç 客æ·ç«¯ï¼é¦å psï¼htmlï¼div+cssè¯å®é½æ¯è¦ä¼çäºï¼ä¸ç¨å¤è¯´ãç¶åå°±æ¯javascriptèæ¬è¯è¨äºï¼é£äºä»ä¹çªå£æå¨åï¼é¡µé¢å è½½åé½æ¯ç¨è¿ä¸ªæ¥åçãç¶å说å°è天åè½ï¼web页é¢æ¯è¯·æ±-æ§è¡çåçï¼ä½æ¯é¡µé¢æ²¡æå·æ°æä¹å°±å¾å°è天信æ¯çå¢ï¼è¿å°±ç¨å°äºajaxææ¯ï¼å ¶å®è¿æ¯å±äºjavascriptèç´ï¼ï¼ç¨ajax模æåæå¡å¨åé请æ±ï¼æå¡å¨å¤çï¼å¾å°æ°æ®ï¼åå°æ°æ®æ¾ç¤ºåºæ¥å°±OKäºã æå¡å¨ç«¯ï¼jspåæ°æ®åºä¸ç»åï¼ä¸»è¦å æ¬è天信æ¯çæ·»å ï¼è天信æ¯çè·åï¼è天信æ¯çæ¥è¯¢ï¼å ¶ä¸è¿äºé¡µé¢é½æ¯ç¨ajaxæ§è¡è¯·æ±çã 建议å»å¦å¦ajaxï¼ç¨å¤å¾å¤§
è®°å¾é纳å