Get parameters passed to a servletTag(s): Servlet/JSP
<HTML> <HEAD></HEAD> <BODY> <FORM METHOD=POST ACTION="/servlet/MyServlet"> value : <INPUT TYPE="TEXT" NAME="someValue"> </FORM> </BODY> </HTML>
import javax.servlet.*; import javax.servlet.http.*; public class MyServlet extends HttpServlet { public void doPost(HttpServletRequest req, HttpServletResponse res) { // note : if "someValue" is missing a null is returned String valuePassed = req.getParameter("someValue"); res.setContentType("text/html"); java.io.PrintWriter out = res.getWriter(); out.println("<html><head></head><body>"); out.println("the value is : " + valuePassed); out.println("</body></html>"); } public void doGet(HttpServletRequest req, HttpServletResponse res) { doPost(req, res); } }