Thing is, I don't use functions in my code. It is just a flow without functions. Putting "return" gave a compile error : "invalid return". What can I do in this kind of scenario?
Thanks, Dimuthu On Fri, Feb 7, 2014 at 10:22 PM, Pradeep Fernando <[email protected]> wrote: > Use a function and then return after redirect.. > > --Pradeep > > > On Fri, Feb 7, 2014 at 9:00 AM, Venura Kahawala <[email protected]> wrote: > >> 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 <[email protected]>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 >>> [email protected] >>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>> >>> >> >> >> -- >> Senior Software Engineer >> >> Mobile: +94 71 82 300 20 >> >> >> _______________________________________________ >> Dev mailing list >> [email protected] >> http://wso2.org/cgi-bin/mailman/listinfo/dev >> >> > > > -- > *Pradeep Fernando* > Associate Technical Lead;WSO2 Inc.; http://wso2.com > > blog: http://pradeepfernando.blogspot.com > m: +94776603662 > -- Dimuthu Upeksha Engineering Intern WSO2 inc.
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
