当用户未使用 Servlet 登录时如何重定向到索引页面? [英] How to redirect to index page when user is not logged using Servlet?

查看:49
本文介绍了当用户未使用 Servlet 登录时如何重定向到索引页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户未使用 servlet 登录,如何重定向到登录页面.

how to redirect to a login page if the user is not logged in using servlet.

我有一个登录页面,用户使用该页面登录并转到主页,导航用户单击注销并点击浏览器中的后退按钮现在页面转到以前访问过的页面,如何重定向用户登录使用servlet时的页面?

I have a login page user logs in using that and goes to home page,after navigating the user clicks on logout and just hits on back button in browser now the page goes to previously visited page, how to redirect the user to login page when using servlet?

感谢您的帮助和持续支持

thanks for the help and continued support

推荐答案

在页面顶部的jsp中使用以下代码

Use the following code in your jsp at the top of the page

if(userName.length()==0 || userType.length()==0 ){
        session.setAttribute("message", "Please Login");
         response.sendRedirect(response.encodeRedirectURL(path+"/"+destination));
    }

这篇关于当用户未使用 Servlet 登录时如何重定向到索引页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆