tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nikita Tovstoles <nik...@eviltwinstudios.net>
Subject cannot copy Request parameters to Map while load testing
Date Mon, 08 May 2006 16:40:23 GMT
Hi,

I'm load-testing my webapp running on Tomcat 5.5.12 (Win) using the 
following URL:

http://localhost:8081/myapp/admin?cmd=test

In doGet() I have this line:

Map<String, String[]> _requestParams = (Map<String, 
String[]>)request.getParameterMap();

In load-testing, Most of the time this requests processes normally, but 
in about 2% of cases I see that:
_requestParams.containsKey("cmd") == false.
As the matter of fact, in those cases _requestParams.size()==0 !

However, in all cases request.getParameter("cmd") returns "test", as 
expected. So, for some reason, 2% of the time _requestParams gets 
assigned a 0-size map, even though a parameter is present. I am really 
puzzled - could someone please suggest why this may be happening as well 
is how can I work around this? (Let's assume I *do* need to end up with 
a Map<String, String[]>

thanks
-nikita

PS. Here's my code until the line in question:

public void doGet(HttpServletRequest request, HttpServletResponse 
response) throws IOException{
   
    response.setContentType("text/html;charset=UTF-8");
    Map<String, String[]> _requestParams = (Map<String, 
String[]>)request.getParameterMap();

        //if(! _requestParams.containsKey("cmd")) { //this fails 2% of 
the time
       String  _command = request.getParameter("cmd"); //this never fails
        if(_command == null) {
            this.getLogger().warning("Invalid request: 
"+requestURLAndSource);
            printParamMap(_requestParams);
            response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Did 
not understand your request");
            return;
        }

    //other stuff
}

    private void printParamMap(Map<String, String[]> paramMap) {
        this.getLogger().info("ParamMap key size: 
"+paramMap.keySet().size());
        for(String key : paramMap.keySet()) {
            this.getLogger().info("KEY="+key);
        }
    }



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


Mime
View raw message