<%
if(登陆成功)
{
%>
<jsp:forward page="a.jsp">
</jsp:forward>
<%
{
else
{
<%
<jsp:forward page="reg.jsp">
</jsp:forward>
}
%>
if(登陆成功)
{
%>
<jsp:forward page="a.jsp">
</jsp:forward>
<%
{
else
{
<%
<jsp:forward page="reg.jsp">
</jsp:forward>
}
%>
解决方案 »
- unitTest, 这种情况要不要做?
- 寻做毕业设计
- java.lang.NoClassDefFoundError: Could not initialize class jihe.Test3
- 在firefox里web打印
- 关于电信级大访问量项目的性能以及数据库压力的调优方案
- 一个数据库的调用问题?
- JavaBean连接数据库的问题。在线等
- 用javamail作发邮件的小程序,想在建立Session时便完成登陆认证的确认,可不知道用什么方法或函数来判断用户输入的用户名和密码吻不温和
- ********权限问题。急急急!!*************
- 我想在服务器端口获得连结上来机子的IP,不知道有什么方法可以实现!!!?
- 如何上传文件?
- javamail 问题?
在用户登入系统后,你用一个session来把用户的名字以及其他的信息(权限.etc)
在你的检测页面可以通过这样的一些代码来实现:
right.jsp
<%
if (session!=null){
String cur_sys = "";
cur_sys = (String)session.getValue("admtype");
if (cur_sys==null||cur_sys.equals("")||!(cur_sys.equals("01")||cur_sys.equals("02")||cur_sys.equals("04"))){
response.sendRedirect("admlogout.jsp");
return;
}
}else{
response.sendRedirect("admlogout.jsp");
return;
}
%>admlogout.jsp页面
<%
if (session!=null) {
session.putValue("admlogin","");
session.putValue("admname","");
session.putValue("admtype","");
response.sendRedirect("admlogin001.jsp");
}
%>你把这个页面right.jsp <%@ page include = "right.jsp"%>
这样就可以了具体的转节页面就你自己来了!
我在点击某个链接的时候,如何取得地址栏中的地址
<%@ page import="java.sql.*" %>
<html>
<head>
<title>处理登陆</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body>
<%
boolean login=true;//代表登陆是否成功
if(login)
{
session.setAttribute("login","yes");
response.sendRedirect("a.jsp");//登陆成功
}
else
response.sendRedirect("reg.jsp");//登陆不成功
%>
</body></html>
然后你在其他jsp页面,如a.jsp,b.jsp等判断session("login")的值,如果不行就跳转到reg.jsp
CoolAbu(阿卜-Never Stop(★★★★))
方法好啊。
假如登入成功就让
session.setAttri("username",username);
然后在判断
username=(String)session.getAttri("username");
是否为NULL或“”
我要在servlet中得到地址栏中的地址??
以下是我的方法,方法是没有错误的
private void doRead(HttpServletRequest request, HttpServletResponse response) throws Exception
{
Status status=new Status(request);//自己定义的类
if(status.login())
{
String url=request.getParameter("url");//这句话又错误
ServletContext servletcontext = getServletContext();
RequestDispatcher requestdispatcher = servletcontext.getRequestDispatcher(url);
requestdispatcher.forward(request, response);
}
else
{
String url="/login.jsp";
ServletContext servletcontext = getServletContext();
RequestDispatcher requestdispatcher = servletcontext.getRequestDispatcher(url);
requestdispatcher.forward(request, response);
}
}
出错是这里String url=request.getRequestURI();
我要在servlet中得到地址栏中的地址??
以下是我的方法,方法是没有错误的
private void doRead(HttpServletRequest request, HttpServletResponse response) throws Exception
{
Status status=new Status(request);//自己定义的类
if(status.login())
{
String url=request.getRequestURI();这句话又错误
ServletContext servletcontext = getServletContext();
RequestDispatcher requestdispatcher = servletcontext.getRequestDispatcher(url);
requestdispatcher.forward(request, response);
}
else
{
String url="/login.jsp";
ServletContext servletcontext = getServletContext();
RequestDispatcher requestdispatcher = servletcontext.getRequestDispatcher(url);
requestdispatcher.forward(request, response);
}
}