You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Nikita Tovstoles <ni...@eviltwinstudios.net> on 2006/05/08 18:40:23 UTC

cannot copy Request parameters to Map while load testing

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