[opencms-dev] Weird inclusion issues with response.sendRedirect()

Andras Balogh andras at reea.net
Tue Jun 22 08:21:01 CEST 2004


    Hello Matthew,

    When you use response.sendRedirect() is not valid to write also the 
the output stream (out.println).
Also make sure you have a return; statement after 
response.sendRedirect() because you probably
 don't want the code to be executed after response.sendRedirect.

Best wishes,
Andras.

Matthew Evans wrote:

> 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 .
>  





More information about the opencms-dev mailing list