I'm trying to set a request attribute so that when the control reaches my servlet i can use it for my own purpose. But on trying to retrieve the attribute and set it some where else i'm getting a NullPointer Exception. Is this because on submit the action taking place is send-redirect instead of forward?
When the user clicks on the Submit button in that form in the browser, it submits a request to your server. That is neither a redirect nor a forward, those are actions which your code may do on the server.
But if you were assuming the request which ran that JSP and generated the HTML containing that form would be the same as the request which later came from the browser when the user clicked the Submit button, that was an incorrect assumption. That isn't how it works. Your JSP generates HTML which is sent to the browser. Later the user may click on controls in that HTML which generate requests.
Thanks Paul I think I understand what you are saying. What I'm trying to do can be easily accomplished using Hidden Field as it would contain the data that would be passed from the browser to the server.