Shopping Cart 1

Source: Internet
Author: User
<% @ Page Language = "Java" Import = "Java. util. * "pageencoding =" gb2312 "%> <HTML> <body> <% arraylist books = new arraylist (); books. add ("Romance of the Three Kingdoms"); books. add ("Journey to the West"); books. add ("Water Margin"); // put books into the session name book session. setattribute ("book", books ); %> <a href = myjsp2.jsp> View shopping cart </a> </body> 

 

<% @ Page Language = "Java" Import = "Java. util. * "pageencoding =" gb2312 "%> <HTML> <body> <form action =" myjsp3.jsp "method =" Post "> enter a book: <input name = "book", type = "text"> <input type = "Submit" value = "add to shopping cart"> </form> <HR> <%
// Retrieve the arraylist book = (arraylist) Session named books. getattribute ("books"); If (Book = NULL) // if not, it is the first time {out. print ("wzz"); book = new arraylist (); Session. setattribute ("books", book);} string book1 = request. getparameter ("book"); If (book1! = NULL) {book1 = new string (book1.getbytes ("ISO-8859-1"); book. add (book1) ;}%> contents in the shopping cart: <br> <% for (INT I = 0; I <book. size (); I ++ ){
// Retrieve out. println (book. Get (I) + "<br>") ;}%> </body>

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.