What is the Java equivalent of PHP's $_POST
? After searching the web for an hour, I'm still nowhere closer.
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.
<html>
<body>
<form method="post" action="/myServlet">
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" />
</form>
</body>
</html>
Now for the Servlet
import java.io.*;
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");
....
....
}
}