[opencms-dev] Re: Weird inclusion issues with response.sendRedirect() (Matthew Evans)

Ariel Spivakovsky ariels at eudoramail.com
Thu Jun 24 03:39:01 CEST 2004


Matthew:

Try this.
It's just a few extra try catch entries and your code works.

<%@ page import="java.util.*,
                 com.opencms.flex.jsp.*,
                 com.opencms.file.*,
                 com.opencms.file.CmsUser" %>



 
<% 
 
try{

com.opencms.flex.jsp.CmsJspActionElement cms = new com.opencms.flex.jsp.CmsJspActionElement(pageContext, request, response);
CmsObject cmso = cms.getCmsObject();
boolean validated = false;
try { 
 
    Vector userGroups = cmso.getDirectGroupsOfUser(cms.user("name")); 
    CmsGroup thisGroup;
 
    for (Enumeration allGroups = userGroups.elements();
allGroups.hasMoreElements();) {
        thisGroup = (CmsGroup)allGroups.nextElement();
        if (thisGroup.getName().equals("Users")){
            validated = true;
          out.println("DEBUG: logged in");

        }
    }
 
} catch (Exception ex) {
  out.println("Error logging in");
}
 

try{
if (!validated) { 
    out.println("redirecting to " + cms.link("/RGLIntranet/login.jsp"));
    response.sendRedirect("/RGLIntranet/login.jsp");
}

} catch (Exception ex) {
  out.println("DEBUG: Error validate");
}
 


} catch (Exception ex) {
  out.println("DEBUG: Error global");
}
 

%>
 


--

--------- Original Message ---------
>--__--__--
>
>Message: 5
>From: "Matthew Evans" <matte at solidstategroup.com>
>To: <opencms-dev at opencms.org>
>Date: Tue, 22 Jun 2004 01:06:37 +0100
>Organization: Solid State Group
>Subject: [opencms-dev] Weird inclusion issues with response.sendRedirect()
>Reply-To: opencms-dev at opencms.org
>
>This is a multi-part message in MIME format.
>
>------=_NextPart_000_001F_01C457F5.2B4F2E30
>Content-Type: text/plain;
>	charset="us-ascii"
>Content-Transfer-Encoding: 7bit
>
>Hi,
> 
>I've been trying to fix this bug all night and it's beate me.
>I need help
> 
>I'm basically checking if someone is logged into the site based on OpenCMS
>with this code:
> 
><%@ page import="java.util.*,
>                 com.opencms.flex.jsp.*,
>                 com.opencms.file.*,
>                 com.opencms.file.CmsUser" %>
> 
><% 
> 
>com.opencms.flex.jsp.CmsJspActionElement cms = new
>com.opencms.flex.jsp.CmsJspActionElement(pageContext, request, response);
>CmsObject cmso = cms.getCmsObject();
>boolean validated = false;
>try { 
> 
>    Vector userGroups = cmso.getDirectGroupsOfUser(cms.user("name")); 
>    CmsGroup thisGroup;
> 
>    for (Enumeration allGroups = userGroups.elements();
>allGroups.hasMoreElements();) {
>        thisGroup = (CmsGroup)allGroups.nextElement();
>        if (thisGroup.getName().equals("Users")){
>            validated = true;
>        }
>    }
> 
>} catch (Exception ex) {
>  out.println("Error logging in");
>}
> 
>
>if (!validated) { 
>    out.println("redirecting to " + cms.link("/RGLIntranet/login.jsp"));
>    //response.sendRedirect("/RGLIntranet/login.jsp");
>}
>%>
> 
> 
>As you can see if they are not logged in as a user they are redirected to a
>login page.
>The problem is, if I uncomment the redirect line I get some kind of
>inclusion loop error, but if I leave the line commented out it works
>perfectly.
>I've checked the login page to see if it is calling a template or anything
>but it isn't so I dont know why it's complaining about an inclusion loop.
> 
>Anyone have any ideas? 
> 
>Cheers,
> 
>M at .
> 


Need a new email address that people can remember
Check out the new EudoraMail at
http://www.eudoramail.com



More information about the opencms-dev mailing list