用户登录界面设计代码jsp(登录界面jsp代码及效果显示)

http://www.itjxue.com  2023-03-02 15:59  来源:未知  点击次数: 

jsp 登陆界面的代码

登录判断的页面代码

%@ page contentType="text/html; charset=gb2312"%

%@ page import="java.sql.*"%

%@ page import="java.util.*"%

%@ include file="conn.jsp"%

%request.setCharacterEncoding("gb2312");

Statement stat=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

String name=request.getParameter("name");

String password=request.getParameter("password");

ResultSet rs=stat.executeQuery("select * from sjb where name='"+name+"'and pass='"+password+"'");

%

%if(rs.next()){%

%String shenfen=rs.getString(6);

session.setAttribute("name",name);

response.sendRedirect("index1.jsp");

}else{

out.print("帐号密码输入错误");%

a href="index1.jsp"点击返回/a

%}%

登录输入时的代码

form action="login.jsp" method="post" name="form1" class="STYLE1" id="form1"

帐号

label

input name="name" type="text" id="name" tabindex="1" size="13" maxlength="13" /

/label

A href="regedit.jsp"注册/A

密码

label

input name="password" type="password" id="password" size="13" maxlength="13" /

/label

a href="forget.jsp"忘记/a

label

input type="submit" name="Submit" value="确定" /

/label

label

input type="reset" name="Submit2" value="重填" /

/label

/form

用jsp怎样做一个用户登录界面

//jsp文件,登录界面

%@page?pageEncoding="utf-8"?contentType="text/html;?charset?=?utf-8"%

body

h1Register/h1

hr?/

form?action="login"?method="post"

用户名:?

input?type="text"?name="username"?id="text"?/

密?码:?

input?type="password"?name="pwd"?id="text"?//

input?type="submit"?value="登录"?id="button"?/

/form

/body

//这是server文件,web.xml部署名字login

import?java.io.IOException;

import?javax.servlet.ServletException;

import?javax.servlet.http.HttpServlet;

import?javax.servlet.http.HttpServletRequest;

import?javax.servlet.http.HttpServletResponse;

import?javax.servlet.http.HttpSession;

public?class?AddUser?extends?HttpServlet?{

public?void?service(HttpServletRequest?request,?HttpServletResponse?response)

throws?ServletException,?IOException?{

response.setContentType("text/html;charset=utf-8");

request.setCharacterEncoding("utf-8");

String?username=request.getParameter("username");

String?pwd=request.getParameter("pwd");

try{

if(username.equals("name")pwd.equals("pwd")?){

????system.out.print("登录成功");

}else{

????system.out.print("error");

}

}catch(Exception?e){

e.printStackTrace();

}

}

}

简单的登录界面,不需要数据库,如果要链接数据库就要判断很多了

编写用户注册于登录的JSP页面的全部程序代码

3个jsp文件,第一个是login.jsp,第二个是judge.jsp,第三个是afterLogin.jsp

%@ page language="java" contentType="text/html; charset=GB18030"

pageEncoding="GB18030"%

%@ page import="java.util.*" %

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

html

head

title登录页面/title

/head

body

form name="loginForm" method="post" action="judgeUser.jsp"

table

tr

td用户名:input type="text" name="userName" id="userName"/td

/tr

tr

td密码:input type="password" name="password" id="password"/td

/tr

tr

tdinput type="submit" value="登录" style="background-color:pink" input type="reset" value="重置" style="background-color:red"/td

/tr

/table

/form

/body

/html

%@ page language="java" contentType="text/html; charset=GB18030"

pageEncoding="GB18030"%

%@ page import="java.util.*" %

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

html

head

title身份验证/title

/head

body

%

request.setCharacterEncoding("GB18030");

String name = request.getParameter("userName");

String password = request.getParameter("password");

if(name.equals("abc") password.equals("123")) {

%

jsp:forward page="afterLogin.jsp"

jsp:param name="userName" value="%=name%"/

/jsp:forward

%

}

else {

%

jsp:forward page="login.jsp"/

%

}

%

/body

/html

%@ page language="java" contentType="text/html; charset=GB18030"

pageEncoding="GB18030"%

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

html

head

title登录成功/title

/head

body

%

request.setCharacterEncoding("GB18030");

String name = request.getParameter("userName");

out.println("欢迎你:" + name);

%

/body

/html

JSP编写一个登陆界面

1、首先准备Dreamweaver8软件,解压安装。如下图所示:这件点击安装程序,然后输入序列号就可以了。

2、在安装软件时候,我们可以看到是否关联【jsp文件】。

3、安装好了软件以后,我们打开Dreamweaver8软件。点击菜单上的【文件】——【新建】。

4、弹出【新建文档】——【动态页】——【jsp】——【创建】。

5、点击【拆分】,在【body】标签下面输入:%? ? ?out.println("Hello World!");? ? ?%。

6、然后按快捷键【ctrl+s】保存jsp文件。保存类型jps;。

求JSP登陆界面代码

给你提供一下思路吧。1.输入界面:输入用户名和密码。2.处理界面:获取提交过来的数据(用户名和密码),然后进行验证。 然后填写正确时,跳转成功的界面;不正确时,跳转失败的界面。3.创建成功界面与失败界面。你看这样能理解吗? 追问: 可以理解,但是我不会写代码。 回答: 那我给你先写一个简单的把。等会啊。 补充: 登录界面:%@ page language="java" pageEncoding="GBK"%htmlheadtitle登录界面/title/headbodydiv align="center"form action="validate.jsp" method="post"用户名:input type="text" name="myName"br密码:input type="password" name="myPass"brinput type="submit" value="登录"/form/div/body/html登录验证界面:%@ page language="java" pageEncoding="GBK"%%//处理中文乱码request.setCharacterEncoding("GBK");//获取提交的元素String pass=request.getParameter("myPass");//业务处理if("admin".equals(name) "admin".equals(pass)){response.sendRedirect("yes.jsp");}else{response.sendRedirect("no.jsp");}%成功界面:%@ page language="java" pageEncoding="GBK"%htmlheadtitle成功界面/title/headbody登录成功!/body/html

(责任编辑:IT教学网)

更多

推荐3DMAX教程文章