title: How to get param value from java servlet
body: <p>I'm trying to get param values passed to a Java Servlet but the string returned is not correct.  I'm storing the values in a Map and checking if the key exists.  </p>
  
  <pre><code>Map params;
  params = request.getParameterMap();
  
  String id = params.get("id").toString();
  String data = params.get("data").toString();
  
  System.out.println("streaming" + data + " with id of " + id);
  </code></pre>
  
  <p>Yet if I call this servlet via <code>http://localhost:8080/Serv/stream/data?data=hereisdata&amp;id=you</code> my output looks like this:</p>
  
  <pre><code>streaming[Ljava.lang.String;@5e2091d3 with id of [Ljava.lang.String;@36314ab8
  </code></pre>
  
  <p>What am I missing?</p>
  
  <p>EDIT:  as the suggested answers are not working, I'm including the entire class as I'm likely messing something up within the class:</p>
  
  <pre><code>import java.util.*;
  import javax.servlet.http.HttpServletRequest;
  import Engine.Streamer;
  
  
  public class AnalyzerController {
  
      private Map params;
      private String pathInfo;
      private HttpServletRequest request;
  
      public AnalyzerController(HttpServletRequest request)
      {
          this.params = request.getParameterMap();
          this.pathInfo = request.getPathInfo();
      }
  
      public void processRequest()
      {
          System.out.println("procing with " + pathInfo);
  
          switch(pathInfo){
          case "/stream/data":
              if(params.containsKey("id") &amp;&amp; params.containsKey("data")) processStream();
              break;
          }
      }
  
      private void processStream()
      {
          System.out.println("we are told to stream");
          String data = request.getParameter("data");
          String id = request.getParameter("id");
          Streamer stream = new Streamer();   
  
          stream.streamInput(data, "Analyzer", id);           
      }
  }
  </code></pre>
  
  <p>This line specifically is throwing the NPE:  <code>String data = request.getParameter("data");</code></p>