我目前正在在线商店中工作,其中商店页面是一个jsp文件。然后,信息被转发到servlet,并显示在另一个jsp文件中。我在Servlet上还剩下多少项目。
如何做到这一点,所以当我加载页面时,第一个jsp文件中剩下多少项目?
这是我的第一个jsp文件:
<html>
<form action="ProcessInfo" method="post">
<label>First Name : </label>
<input type="text" name="fname"><br><br>
<label>Last Name : </label>
<input type="text" name="lname"><br><br>
<label>Contact Info : </label>
<input type="text" name="Contact_Info" value="IG,SC,etc"><br><br>
<label>M&M $1 per </label>
<input type="text" id ="MM" name="MM" value="0" ><br><br>
<label>Skittles $1 per </label>
<input type="text" id="Skittles" name="Skittles" value="0" ><br><br>
</div>
<input type="submit" value="Send">
</form>
这是我的servlet:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String url ="/DisplayInfo.jsp";
String MM = request.getParameter("MM");
String Skittles = request.getParameter("Skittles");
String Contact_Info = request.getParameter("Contact_Info");
//I create a customer object here called customer
request.setAttribute("customer", customer);
getServletContext().getRequestDispatcher(url).forward(request, response);
}
这是我的显示信息的jsp
<html>
<label>Name:</label>
${cust.getfName()}<br>
<label>Meeting Location:</label>
${cust.getMeeting_Location()}<br>
<label>Contact Information:</label>
${cust.getContact_Info()}<br>
</html>