Mar 1st, 2013, 04:23 AM
Navigation of page between the two action
I am facing an issue just give u background of it. I have an application build using Spring MVC. After sign in I have page where I am doing some action on click of button "Accept" and on top of page I have "Log Off" button.
Here facing issue when I am clicking on "Accept" button doing some prepossessing and in between before completing this "Accept" action I am doing Log Off which actually clearing session and showing Log Off page. As some of the session attributes are used in Accept action I am getting Null Pointer Exception. When Null Pointer Exception is thrown I have written logic for redirecting control to Log In page with error message but for me Log Off page is shown.
My question is that, as my Log Off action is completed before Accept action and as exception is thrown in Accept action I am transferring control to Log In page. I am expecting Log In page with error to display but Log Off page is displayed. How the Spring MVC actions are working in this case, is it as per specification?
Mar 1st, 2013, 05:32 AM
Http is stateless and you can have multiple requests from the same client.... They aren't sequentially so the behavior is correct as the process action has no listeners anymore the response basically goes nowhere.
Creating something that depends on the session might not be the smartest thing to do, I would pull out all needed things and do the processing that way you don't have the dependency on the session anymore, limiting this possible error.
Mar 3rd, 2013, 11:48 PM
Thanks Marten. I agree with point that we should not depend on Session.
But still not understanding the point "the process action has no listeners anymore the response basically goes nowhere". Actually I feel as the action in the same context it should redirect.
Mar 4th, 2013, 01:35 AM
You execute request1, processing is taking a while, users clicks button, request 2, handled quickly returns and redirects. Now there is nothing anymore, on the client, that listens/reponds to request1. Remember the web is async, stateless so each request is handled as a standalone new request it doesn't know context, order or whatever it is just that a request.
Mar 4th, 2013, 03:24 AM
So even if request1 has logic to forward/redirect some action, it will not have any effect as there nothing on client to listen/responds to request1. What if request1 is redirecting just a jsp ?
Tags for this Thread