The title says it all. All I really want is the equivalent of PHP's $_POST[], and after searching the web for an hour, I'm still nowhere closer.

+4  A: 

Your HttpServletRequest object has a getParameter(String paramName) method that can be used to get parameter values.

Ryan Ahearn
+3  A: 

POST variables should be accessible via the request object: HttpRequest.getParameterMap(). The exception is if the form is sending multipart MIME data (the FORM has enctype="multipart/form-data"). 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 Commons File Upload API.

+7  A: 

Here's a simple example. I didn't get fancy with the html or the servlet, but you should get the idea.

I hope this helps you out.

<form method="post" action="/myServlet">
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" />

Now for the Servlet

import javax.servlet.*;
import javax.servlet.http.*;

public class MyServlet extends HttpServlet {
  public void doPost(HttpServletRequest request,
                    HttpServletResponse response)
      throws ServletException, IOException {

    String userName = request.getParameter("username");
    String password = request.getParameter("password");
Shouldn't the servlet method should be doPost not doGet since you want it to run on the form POST not the GET?
Yeah you're right. I got in a hurry. I probably copied it and pasted it. I fixed it now though. Thanks!