NullPointer on old Request
1 posts in topic
Flat View  Flat View

Posted By:   claudio_signorini
Posted On:   Wednesday, July 23, 2003 03:11 AM


I have got this scenario.

I call a servlet, this servlet stores the HttpServletRequest in the HttpSession and does a forward to a JSP. When the servlet in called again it takes the old HttpServletRequest from the HttpSession and re-calls the "service" method with this old request. Then it calls the getMethod on the request and a "NullPointerException" is thrown.

It seems like when the first servlet call is finisched it clear che request so that I can't reuse it later.

Do you know any way to avoid this?



Re: NullPointer on old Request

Posted By:   Christopher_Koenigsberg  
Posted On:   Wednesday, July 23, 2003 06:36 AM

Don't try to reuse a transient, stateful object, like a Request, after its lifetime is over! especially since you don't have control over its lifecycle.

Instead copy what you need out of it, into a value object of your own design, and store/reuse that instead.

About | Sitemap | Contact