/* $Id: RequestParamExample.java 24-jul-2004.22:16:29 hhildebr Exp $ * */ import java.io.*; import java.text.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; /** * Example servlet showing request headers * * @author James Duncan Davidson */ public class RequestParamExample extends HttpServlet { ResourceBundle rb = ResourceBundle.getBundle("LocalStrings"); public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println(""); out.println(""); out.println(""); String title = rb.getString("requestparams.title"); out.println("" + title + ""); out.println(""); out.println(""); // img stuff not req'd for source code html showing // all links relative out.println(""); out.println("\"view"); out.println(""); out.println("\"return\""); out.println("

" + title + "

"); String firstName = request.getParameter("firstname"); String lastName = request.getParameter("lastname"); out.println(rb.getString("requestparams.params-in-req") + "
"); if (firstName != null || lastName != null) { out.println(rb.getString("requestparams.firstname")); out.println(" = " + DemoUtil.HTMLReplace(firstName) + "
"); out.println(rb.getString("requestparams.lastname")); out.println(" = " + DemoUtil.HTMLReplace(lastName)); } else { out.println(rb.getString("requestparams.no-params")); } out.println("

"); out.print("

"); out.println(rb.getString("requestparams.firstname")); out.println(""); out.println("
"); out.println(rb.getString("requestparams.lastname")); out.println(""); out.println("
"); out.println(""); out.println("
"); out.println(""); out.println(""); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { doGet(request, response); } }