tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Calum <cal...@gmail.com>
Subject Re: Null-pointer exception from response.encodeUrl under Windows Tomcat 7
Date Mon, 20 Jun 2011 10:12:03 GMT
On 15 June 2011 18:54, Konstantin Kolinko <knst.kolinko@gmail.com> wrote:
> The request and response objects must never be accessed outside the
> request processing cycle.  The objects are recycled and cleared or
> reused for subsequent request and responses, and are not guaranteed to
> be thread-safe.  The consequences can be severe.

I was interested by this.
So:

    private Service service;

    @Override
    public void init() throws ServletException {
        super.init();
        service = (Service)
WebApplicationContextUtils.getWebApplicationContext(getServletContext()).getBean("service");
    }

    protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
            throws ServletException, IOException {
    service.logHit(request);
    ....
    }


is a bad thing?
Could you explain why?
I would assume that a new request object is created each time, and
that while something has a reference to it, it will be fine, and when
logHit has finished with it, it will be eligible for garbage
collection.


Calum

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message