jsp session handling

    I having lot of trouble login in at the same time. here is the scenario.
    When I login here is the flow of events
    Jsp---> sends commend to servlet --> calls Business Objects --> calls DAO's --> talks to the SSO and the local database for authentication..
   This is an J2EE application residing under ATG Dynamo server. But we are not using any of the ATG session handling.. We have our own session handling classes defined to manage sessions.
   Here is the problem.. Basically I noticed two problems.
 1)  When two Users tried to login at the same time. Only one user will able to login and the second user was shown the blank page with the message

java.lang.IllegalStateException: Redirect not allowed; response is already committed.
        at atg.servlet.DynamoHttpServletResponse.sendRedirect(DynamoHttpServletResponse.java:943)
        at com.attws.mms.TSDSecurity.controller.BaseController.dispatch(BaseController.java:397)
        at com.attws.mms.TSDSecurity.controller.BaseController.doPost(BaseController.java:502)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
                                                                 at com.attws.mms.TSDSecurity.controller.BaseController.service(BaseController.java:417)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
                                                                 at atg.servlet.container.WebApplication.dispatchServlet(WebApplication.java:1188)
        at atg.servlet.container.WebApplication.dispatchServlet(WebApplication.java:1035)
        at atg.servlet.container.FilterChainImpl.dispatchServlet(FilterChainImpl.java:320)
        at atg.servlet.container.NullFilterChain.doFilter(NullFilterChain.java:116)
        at atg.servlet.container.FilterChainImpl.execute(FilterChainImpl.java:219)
        at atg.servlet.container.WebApplication.dispatchServlet(WebApplication.java:1007)
        at atg.servlet.container.WebApplication.dispatchRequest(WebApplication.java:642)
        at atg.servlet.container.WebApplication.dispatchRequest(WebApplication.java:503)
        at atg.servlet.pipeline.WebApplicationDispatcherPipelineServlet.service(WebApplicationDispatcherPipelineServlet.java:66)
                                                                                                                          at atg.servlet.pipeline.PipelineableServletImpl.
        at atg.servlet.security.ThreadUserBinderServlet.service(ThreadUserBinderServlet.java:90)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:115)
        at atg.servlet.security.FormLoginPipelineServlet.service(FormLoginPipelineServlet.java:156)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:115)
        at atg.userprofiling.AccessControlServlet.service(AccessControlServlet.java:558)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:115)
        at atg.userprofiling.PageEventTriggerPipelineServlet.service(PageEventTriggerPipelineServlet.java:168)

When you refresh the page you will be able to see the page comming

  2) We logged in as different users at the same time. A blank page with the above message comes up and then when I refresh for my wonder both of us are getting the same user info.. This does not happen always.. But still this happend couple of times. I know for sure this could be something to do with session handling. But I dont have any control on sessionManager class files.I dont know What I can do to handle this happening. Is there anything that I can try from JSP page like making sure we always have a unique session throughout the session? I'm using redirect everywhere... Please let me know if you need more information

Please help me out with the solution.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It seems that you have a synchronization problem with your session handling.
1. Your JSP calls the same servlet instance somehow, or sends it an incorrect version of the request/response objects. Can you paste the JSP code?
2. Looks like the same problem as 1.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
On no. 1, the exception will occur if the response has already be flushed/sent prior to calling the sendRedirect().  If the session handling classes were done correctly, different threads should have been created to handle various sessions.  There shouldn't be any session issues there.  The problem then may be in your session handling mechanism.  Why not just use the built-in session handling mechanism of your server?  That's what these tools are for, so that you can do away with such tasks and instead concentrate with building your application.
can we have a loot at this servlet in full: BaseController.java:397?
Mayank SAssociate Director - Product EngineeringCommented:
Does your Servlet, by any chance, implement the SingleThreadModel?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.