jsp judges the value in the session

There are two methods:

Suppose, the name of this session is adminAccount

1. EL expression

  <script type="text/javascript">
       if($.trim("${sessionScope.adminAccount}") == "")
       {
             top.location.href="admin.jsp";
       }
  </script>

2. java code

  <%
       if(session.getAttribute("adminAccount")==null || session.getAttribute("adminAccount")=="")

       {
             String path = request.getContextPath();
             String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/"; 
             response.sendRedirect(basePath+"admin.jsp");
       }
  %>

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326964464&siteId=291194637