Hi, You need to add a return statement at the end of the redirect. So it will look like below
*response.sendRedirect("/InfraPortal/login.jag");* *return;* The issue is happening even though you redirect to the login page, flow in the sane page will execute and you might have another redirect at the end. Regards, Venura On Thu, Feb 6, 2014 at 10:47 PM, Dimuthu Upeksha <dimut...@wso2.com> wrote: > Hi all, > > In our project we use following commands to see whether an user has signed > in to the system. > > ------------- > > var user = session.get("user"); > > if(user==null){ > > response.sendRedirect("/InfraPortal/login.jag"); > > } > > //some jaggery code > > ------------ > > What I need to do is, to see whether there is an user object in session > scope. If it's not redirect to login page. If user exists, it just skips > those lines and run rest of the code. > > Problem is when user object is null. Then response.sendRedirect method is > invoked and server gives > > java.lang.IllegalStateException: Cannot call sendError() after the response > has been committed > > org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:451) > > org.jaggeryjs.jaggery.core.manager.WebAppManager.execute(WebAppManager.java:438) > org.jaggeryjs.jaggery.core.JaggeryServlet.doGet(JaggeryServlet.java:24) > javax.servlet.http.HttpServlet.service(HttpServlet.java:735) > javax.servlet.http.HttpServlet.service(HttpServlet.java:848) > org.jaggeryjs.jaggery.core.JaggeryFilter.doFilter(JaggeryFilter.java:21) > > It seems like rest of the code below response.sendRedirect method has been > executed although it has redirected to login page. How can I stop executing > that code below "response.sendRedirect" method? > > > -- > Dimuthu Upeksha > Engineering Intern > WSO2 inc. > > _______________________________________________ > Dev mailing list > Dev@wso2.org > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- Senior Software Engineer Mobile: +94 71 82 300 20
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev