tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 51445] New: Tomcat 7 SingleThreadModel Problem
Date Tue, 28 Jun 2011 10:33:26 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=51445

             Bug #: 51445
           Summary: Tomcat 7 SingleThreadModel Problem
           Product: Tomcat 7
           Version: 7.0.12
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: bhatu.mali@gmail.com
    Classification: Unclassified


I have noticed that in tomcat 7 if we implement SingleThreadModel and
initialize some variables into init(ServletConfig config) method, in that case
values initialized in init(ServletConfig config) not reflected into service
block.

For Example : Following code will print "0".

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.SingleThreadModel;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class test extends HttpServlet implements SingleThreadModel
{

    int i = 0;

    @Override
    public void init(ServletConfig config) throws ServletException
    {
        super.init(config);
        i = 10;
    }
    protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
            throws ServletException, IOException
    {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try
        {
            out.println(i);
        }
        finally
        {
            out.close();
        }
    }
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse
response)
            throws ServletException, IOException
    {
        processRequest(request, response);
    }
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse
response)
            throws ServletException, IOException
    {
        processRequest(request, response);
    }
    @Override
    public String getServletInfo()
    {
        return "Short description";
    }
}

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


Mime
View raw message