不过,有些人可能会说这两个请求几乎相同。但是,当然,这里有区别,下面的代码清楚地说明了两者的区别。
在这里,我们从用户采取投入和操作设置为output.jsp的用的方法POST,使用POST和GET将在我们未来的教程覆盖。
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Diff b/w INCLUDE & FORWARD</title> <style type="text/css"> body{ text-align:center; } p{ font-size:16pt; } h1{ background-color:lightblue; } </style> </head> <body> <!-- taking inputs from the user & action triggering to output.jsp --> <h1>DIFFERENCE BETWEEN INCLUDE AND FORWARD REQUEST IN JSP</h1> <form action="output.jsp" method="post"> <p><label>USER NAME :</label> <input type="text" name="username"></p> <p><label>PASSWORD :</label> <input type="password" name="password"></p> <p><label>GENDER : </label> <input type="radio" name="gender" value="Male">MALE <input type="radio" name="gender" value="Female">FEMALE</p> <p> <label>DEPARTMENT :</label> <select name="department" required> <option value="">Select</option> <option value="Training">Training</option> <option value="Marketing">Marketing</option> <option value="Testing">Testing</option> </select> </p> <p><label>LANGUAGES KNOWN :</label><input type="checkbox" name="lgknown" value="Telugu">TELUGU <input type="checkbox" name="lgknown" value="Hindi">HINDI <input type="checkbox" name="lgknown"value="English" >ENGLISH </p> <button>SAVE</button> </form> </body> </html>