<p>What is the Java equivalent of PHP's <code>$_POST</code>? After searching the web for an hour, I'm still nowhere closer.</p>

[{'answer_id': 5224, 'author': 'Ryan Ahearn', 'author_id': 75, 'author_profile': 'https://Stackoverflow.com/users/75', 'pm_score': 7, 'selected': True, 'text': '<p>Your <code>HttpServletRequest</code> object has a <code>getParameter(String paramName)</code> method that can be used to get parameter values.  <a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getParameter(java.lang.String)" rel="noreferrer">http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getParameter(java.lang.String)</a></p>\n'}, {'answer_id': 5227, 'author': 'McDowell', 'author_id': 304, 'author_profile': 'https://Stackoverflow.com/users/304', 'pm_score': 5, 'selected': False, 'text': '<p>POST variables should be accessible via the request object: <a href="http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/ServletRequest.html#getParameterMap()" rel="noreferrer">HttpRequest.getParameterMap()</a>. The exception is if the form is sending multipart MIME data (the FORM has <strong>enctype="multipart/form-data"</strong>). In that case, you need to parse the byte stream with a MIME parser. You can write your own or use an existing one like the Apache <a href="http://commons.apache.org/fileupload/" rel="noreferrer">Commons File Upload</a> API.</p>\n'}, {'answer_id': 11042, 'author': 'ScArcher2', 'author_id': 1310, 'author_profile': 'https://Stackoverflow.com/users/1310', 'pm_score': 6, 'selected': False, 'text': '<p>Here\'s a simple example. I didn\'t get fancy with the html or the servlet, but you should get the idea.</p>\n\n<p>I hope this helps you out.</p>\n\n<pre><code>&lt;html&gt;\n&lt;body&gt;\n&lt;form method="post" action="/myServlet"&gt;\n&lt;input type="text" name="username" /&gt;\n&lt;input type="password" name="password" /&gt;\n&lt;input type="submit" /&gt;\n&lt;/form&gt;\n&lt;/body&gt;\n&lt;/html&gt;\n</code></pre>\n\n<p>Now for the Servlet</p>\n\n<pre><code>import java.io.*;\nimport javax.servlet.*;\nimport javax.servlet.http.*;\n\npublic class MyServlet extends HttpServlet {\n  public void doPost(HttpServletRequest request,\n                    HttpServletResponse response)\n      throws ServletException, IOException {\n\n    String userName = request.getParameter("username");\n    String password = request.getParameter("password");\n    ....\n    ....\n  }\n}\n</code></pre>\n'}, {'answer_id': 40784913, 'author': 'hgc2002', 'author_id': 1460240, 'author_profile': 'https://Stackoverflow.com/users/1460240', 'pm_score': 2, 'selected': False, 'text': '<p>The previous answers are correct but remember to use the name attribute in the input fields (html form) or you won\'t get anything. Example:</p>\n\n<p><code>\n    &lt;input type="text" id="username" /&gt; &lt;!-- won\'t work --&gt;\n    &lt;input type="text" name="username" /&gt; &lt;!-- will work --&gt;\n    &lt;input type="text" name="username" id="username" /&gt; &lt;!-- will work too --&gt;\n</code></p>\n\n<p>All this code is HTML valid, but using getParameter(java.lang.String) you will need the name attribute been set in all parameters you want to receive.</p>\n'}, {'answer_id': 49922035, 'author': 'Siddappa Walake', 'author_id': 6188955, 'author_profile': 'https://Stackoverflow.com/users/6188955', 'pm_score': 1, 'selected': False, 'text': '<p>For getting all post parameters there is Map which contains request param name as key and param value as key.</p>\n\n<pre><code>Map params = servReq.getParameterMap();\n</code></pre>\n\n<p>And to get parameters with known name normal</p>\n\n<pre><code>String userId=servReq.getParameter("user_id");\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/5222', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/429/']