View Single Post
Old 07-06-2004, 06:20 PM   #2 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,161
Belisarius is on a distinguished road
I use the jsp:useBean tag, but what you're doing in principle should work. I'm a bit confused by "session.getValue("u")", as you did a "session.putValue("user",u)", so where the "u" comes from I'm not sure.

Here's how I do it.

Code:
<jsp:useBean id="user" class="dec.common.beans.UserBean" scope="session" />
<jsp:useBean id="error" class="dec.common.beans.ErrorBean" scope="session" />

<%
  String host = request.getServerName();
  String path = request.getRequestURI();
  if(user == null){
%>
  <jsp:forward page="/index.jsp" />
<%
  }else if(user.getUser() == null){
%>
  <jsp:forward page="/index.jsp" />
<%
  }else if(!user.getAuth()){
%>
  <jsp:forward page="/index.jsp" />
<%
  }else if(!request.isSecure()){
    response.sendRedirect(response.encodeRedirectURL("https://" + host + path))
  }
%>
__________________
GitS
Belisarius is offline   Reply With Quote