Thursday, February 6, 2014

How to check the html button request value using JSP

Below shows you how to check the html button request value using JSP:



















JSP file:
<html>
<head>
  <title>E-bookshop</title>
  <style type="text/css">
    body {background-color:gray; font-size=10pt;}
    H1 {font-size:20pt;}
    table {background-color:white;}
    </style>
  </head>
<body>
  <H1>Your online Bookshop</H1>
  <hr/><p/>
<form name="addForm" method="POST">
      <input type="hidden" name="do_this" value="add">
      Book:
      <select name=book>
<option>Learn HTML5 and JavaScript for iOS. Scott Preston $39.99</option>
<option>Java 7 for Absolute Beginners. Jay Bryant $39.99</option>

</select>
      Quantity: <input type="text" name="qty" size="3" value="1">
      <input type="submit" value="Add to Cart">
      </form>
    <p/>

      <form name="checkoutForm"  method="POST">
        <input type="hidden" name="do_this" value="checkout">
        <input type="submit" value="Checkout">
        </form>
<br/>
<%=request.getParameter("do_this") %>
</body>
</html>

No comments:

Post a Comment