Jsp shopping cart

i am new to jsp and am trying to create a shopping cart i have found some code but as it is older code i cant get it to work on the latest version, The following wont compile and i get these errors
C:\Inetpub\wwwroot\jsp\ShoppingServlet.java:3: package javax.servlet does not exist
C:\Inetpub\wwwroot\jsp\ShoppingServlet.java:4: package javax.servlet.http does not exist
i have placed the files in my root directory on IIS, can anyone help, I
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import shopping.CD;
public class ShoppingServlet extends HttpServlet {
public void init(ServletConfig conf) throws ServletException {
super.init(conf);
public void doPost (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
HttpSession session = req.getSession(false);
if (session == null) {
res.sendRedirect("http://localhost:8080/error.html");
Vector buylist=
(Vector)session.getValue("shopping.shoppingcart");
String action = req.getParameter("action");
if (!action.equals("CHECKOUT")) {
if (action.equals("DELETE")) {
String del = req.getParameter("delindex");
int d = (new Integer(del)).intValue();
buylist.removeElementAt(d);
} else if (action.equals("ADD")) {
//any previous buys of same cd?
boolean match=false;
CD aCD = getCD(req);
if (buylist==null) {
//add first cd to the cart
buylist = new Vector(); //first order
buylist.addElement(aCD);
} else { // not first buy
for (int i=0; i< buylist.size(); i++) {
CD cd = (CD) buylist.elementAt(i);
if (cd.getAlbum().equals(aCD.getAlbum())) {
cd.setQuantity(cd.getQuantity()+aCD.getQuantity());
buylist.setElementAt(cd,i);
match = true;
} //end of if name matches
} // end of for
if (!match)
buylist.addElement(aCD);
session.putValue("shopping.shoppingcart", buylist);
String url="/jsp/shopping/EShop.jsp";
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher(url);
rd.forward(req, res);
} else if (action.equals("CHECKOUT")) {
float total =0;
for (int i=0; i< buylist.size();i++) {
CD anOrder = (CD) buylist.elementAt(i);
float price= anOrder.getPrice();
int qty = anOrder.getQuantity();
total += (price * qty);
total += 0.005;
String amount = new Float(total).toString();
int n = amount.indexOf('.');
amount = amount.substring(0,n+3);
req.setAttribute("amount",amount);
String url="/jsp/shopping/Checkout.jsp";
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher(url);
rd.forward(req,res);
private CD getCD(HttpServletRequest req) {
//imagine if all this was in a scriptlet...ugly, eh?
String myCd = req.getParameter("CD");
String qty = req.getParameter("qty");
StringTokenizer t = new StringTokenizer(myCd,"|");
String album= t.nextToken();
String artist = t.nextToken();
String country = t.nextToken();
String price = t.nextToken();
price = price.replace('$',' ').trim();
CD cd = new CD();
cd.setAlbum(album);
cd.setArtist(artist);
cd.setCountry(country);
cd.setPrice((new Float(price)).floatValue());
cd.setQuantity((new Integer(qty)).intValue());
return cd;

Original Post
i have placed the files in my root directory on IIS, can anyone help, IJava-Queries Post
hi!
i guess u r using the servlet engine(ServletRunner) that comes along with jsdk. what's ur version? what u do is, set the classpath to where ever u have the jsdk directory, if u dont use any IDE, type this in the dos prompt, (for eg, ur jsdk is in local c drive)
c:\ set classpath=c:\jsdk4.0\lib;
then compile the file, if u use an IDE, what's that u r using?
>>>
The problem here is that the OP does not know that a web server is needed to run JSP or is it a Typo
-Regards
Manikantan

Similar Messages

  • JSP Shopping Cart problem

    Hello,
    I'm writing a JSP page with a shopping cart so the user can add products to it, nfortunately the thing won't work.. I keep getting an NullPointerException.. I'm probably screwing up somewhere.. I would be very thankful if you could help me out..
    this is the code for the Shopping Cart Bean:
    [myCart.java]
    package myCart;
    import java.util.*;
    public class myCart implements java.io.Serializable{
         private Vector items;
    public String[] getItems(){
         String strTemp[] = new String[items.size()];
         items.copyInto(strTemp);
         return strTemp;
    public void setItems(Vector newItems){
         items=newItems;
    public void addItem(String newId){
         items.addElement(newId);
    This is the JSP page that I'm using:
    [myCart.jsp]
    <%@ page import="java.sql.*" %>
    <%@ page import="java.util.*" %>
    <jsp:useBean id="myCart" class="myCart.myCart" scope="session" />
    <%
    Connection con;
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:produkten");
    Statement stmt = con.createStatement();
         ResultSet rs = stmt.executeQuery("SELECT * FROM tblProdukten WHERE NR= "+request.getParameter("nr")+"");
    while (rs.next()) {
         String merk = rs.getString("MERK");
         long temp = rs.getLong("NR");
         String nr = Long.toString(temp);
    -----> myCart.addItem(nr);
         %>
         <BR>Nr     : <%=nr%>
         <BR>test :     <%=merk%>
         <HR>
    <% } %>
    <%
         con.close();
         catch(ClassNotFoundException cnfex)
              out.println("jdbc odbc driver not found // muzz");
         catch(SQLException sqlex)     
              out.println(sqlex);
    %>
    </TABLE>
    </BODY>
    </HTML>
    I think I probably(??) put the <myCart.addItem> in the wrong part of the code..??
    Greetings,
    Michael

    yes, I see, I forgot to initiate that, I'm still
    learning so please bare with me :)
    I now initiated the <items> vector like this:
    Vector items = new Vector();
    and added this:
    myCart.items.addItem(nr);
    But it still won't work correctly >>
    First error: Your Vector items is not a public variable. Therefore, outside classes will not be able to access it. No problem though, you have a method to take care of that. Instead of what you're doing, simply call
    myCart.addItem(nr)This calls the public method addItem(String) which accesses your private Vector items, and adds a string to the vector.
    Your second error should be taken care of. It is resulting from the fact that instead of calling the method addItem() from teh class instance, youre trying to access the Vector items first, and then trying to call addItem() from that... not only can you not access that variable, as stated above, but there is no method in Vector called addItems(). You could conceivably make items public, but I'd stick with what you've got.

  • Hi, JSP Shopping Cart??

    Hi, i need to make a very simple shopping cart using JSP,
    Can anyone show me the way forward or does anyone have any sample coding for me to look at?
    I need it to be simple as all i want to do is send items to a shopping cart and then feed to a database...
    I can do the database bit... and i can list the items... but i dont have a clue how to store the items in a session... any help is appreciated

    You are falling into a trap here friend. You are trying to do it the easy way by asking for help, that is not going to help you at all because that gap of missing knowledge will stay, you want to fill it on your own. The only thing to do is sit down and put some idea's on paper, using well known techniques such as UML preferably, and keep thinking until you have something that you can work with. But you can use what you know. For example, you know how to store the information in a database, so you have a data structure. Is it so hard for you to translate that data structure into an object structure? I can image...
    1) a ShoppingCart class
    2) some kind of data storage inside it
    3) methods to store and retrieve the information
    the data storage will be the biggest problem. If it is very simple then a HashMap could even work, otherwise you will need to create some beans that can hold your data (or even a combination of a HashMap and beans). Most likely the beans will have attributes that directly match your database tables.
    when you have your ShoppingCart class with its logic to store and retrieve information, you can put that object in the session. I'm sure you can find a tutorial about using the session in java web environments, we are talking about the HttpSession object, that should get you started.

  • Does anyone know any good JSP shopping cart tutorials?

    Can anyone recommend any complete beginners guide to this type of thing?
    To create a cart which takes items from the database and inputs them into a cart.

    try to search on oracle

  • How to create a shopping cart in JSP?

    I am creating an online product ordering system, How can i create a shopping cart in jsp? is there a way i can save a table containg itemcode, price, quantity in jsp? Can i save it using bean or session? please help me. thanks in advance.

    Hello,
    i want to create online shopping cart using html and JSP.
    At first i want to create 1html page where login ad logup optios are provided. After his login, a JSP page containing 3 links namly T-shirts,Jeanspat and Formals is displayed.
    After user select any of the link it must go to particular page.
    There, option of color, size is provided.
    And some 5 to 6 items are displayed with its pfxd prices.
    And in the same page a cart is provided. Whe the user selects(clicks) any item the same must display in cart.
    In the same page link to T-shirts,Jeanspat and Formals is displayed agaiT-shirts,Jeanspat and Formals is displayed agaiT-shirts,Jeanspat and Formals is privided again.
    next page must show the items selected. And finally it must show the "thank you" page stating that your delivary will be delivered to you within 24 hrs.
    Thanks in advance ,
    sameer

  • Newbie - JSP & bean shopping cart logic error?

    Hello,
    I am attempting to bulid a shopping cart facility on a JSP site that I am building.
    I am having difficulties adding an item to the basket.
    The page below (bookDetail.jsp) displays items for sale from a database. At the foot of the page, I have set up a hyperlink to add an item to a basket bean instance created in this page.
    What happens is the page will load correctly, when i hover the mouse over the hyperlink to add the item to the basket, the status bar shows the URL of the current page with the details of the book appended. This is what I want. But when I click the link, the page will only reload showing 20% of the content.
    Netbeans throws up no errors, neither does Tomcat, so I am assuming I have made a logical error somewhere.
    I have enclosed the Book class, and the ShoppingCart class for your reference.
    Any help would be really appreciated as I am at a loss here.
    Cheers.
    Edited highlights from bookDetail.jsp
    //page header importing 2 classes - Book and ShoppingCart
    <%@ page import="java.util.*, java.sql.*, com.shopengine.Book, com.shopengine.ShoppingCart" errorPage="errorpage.jsp" %>
    //declare variables to store data retrieved from database
    String rs_BookDetail_bookRef = null;
    String rs_BookDetail_bookTitle = null;
    String rs_BookDetail_author = null;
    String rs_BookDetail_price = null;
    //code that retrieves recordset data, displays it, and places it in variables shown above
    <%=(((rs_BookDetail_bookRef = rs_BookDetail.getString("book_ref"))==null || rs_BookDetail.wasNull())?"":rs_BookDetail_bookRef)%>
    <%=(((rs_BookDetail_author = rs_BookDetail.getString("author"))==null || rs_BookDetail.wasNull())?"":rs_BookDetail_author)%>
    <%=(((rs_BookDetail_bookTitle = rs_BookDetail.getString("book_title"))==null || rs_BookDetail.wasNull())?"":rs_BookDetail_bookTitle)%>
    <%=(((rs_BookDetail_price = rs_BookDetail.getString("price"))==null || rs_BookDetail.wasNull())?"":rs_BookDetail_price)%>
    //this link is to THIS PAGE to send data to server as request parameters in Key/Value pairs
    // this facilitates the add to basket function
    <a href="<%= response.encodeURL(bookDetail.jsp?title=
    "+rs_BookDetail_bookTitle+"
    &item_id=
    "+rs_BookDetail_bookRef +"
    &author="+rs_BookDetail_author +"
    &price=
    "+rs_BookDetail_price) %> ">
    <img src="images\addtobasket.gif" border="0" alt="Add To Basket"></a></td>
    // use a bean instance to store basket items
    <jsp:useBean id="basket" class="ShoppingCart" scope="session"/>
    <% String title = request.getParameter("title");
    if(title!=null)
    String item_id = request.getParameter("item_id");
    double price = Double.parseDouble(request.getParameter("price"));
    Book item = new Book(item_id, title, author, price);
    basket.addToBasket( item );
    %>
    ShoppingCart class that is used as a bean in bookDetail.jsp shown above
    package com.shopengine;
    //import packages
    import java.util.*;
    //does not declare explicit constructor which automatically creates a zero argument constructor
    //as this class will be instantiated as a bean
    public class ShoppingCart
    //using private instance variables as per JavaBean api
         private Vector basket;
         public ShoppingCart()
              basket = new Vector();
         }//close constructor
    //add object to vector
         public void addToBasket (Book book)
              basket.addElement(book);
         }//close addToBasket method
    //if strings are equal, delete object from vector
         public void deleteFromBasket (String foo)
    for(Enumeration enum = getBasketContents();
    enum.hasMoreElements();)
    //enumerate elements in vector
    Book item = (Book)enum.nextElement();
    //if BookRef is equal to Ref of item for deletion
    //then delete object from vector.
    if (item.getBookRef().equals(foo))
    basket.removeElement(item);
    break;
    }//close if statement
    }//close for loop
         }//close deleteFromBasket method
    //overwrite vector with new empty vector for next customer
         public void emptyBasket()
    basket = new Vector();
         }//close emptyBasket method
         //return size of vector to show how many items it contains
    public int getSizeOfBasket()
    return basket.size();
         }//close getSizeOfBasket method
    //return objects stored in Vector
         public Enumeration getBasketContents()
    return basket.elements();
         }//close getBasketContents method
         public double getTotalPrice()
    //collect book objects using getBasketContents method
    Enumeration enum = getBasketContents();
    //instantiate variable to accrue billng total for each enummeration
    double totalBillAmount;
    //instantiate object to store data for each enummeration
    Book item;
    //create a loop to add up the total cost of items in basket
    for (totalBillAmount=0.0D; enum.hasMoreElements(); totalBillAmount += item.getPrice())
    item = (Book)enum.nextElement();
    }//close for loop
    return totalBillAmount;
         }//close getTotalPrice method
    }//close shopping cart class
    Book Class that is used as an object model for items stored in basket
    package com.shopengine;
    import java.util.*;
    public class Book{
         //define variables
    private String bookRef, bookTitle, author;
         private double price;
    //define class
    public Book(String bookRef, String bookTitle, String author, double price)
    this.bookRef= bookRef;
    this.bookTitle=bookTitle;
    this.author=author;
    this.price=price;
    //create accessor methods
         public String getBookRef()
              return this.bookRef;
         public String getBookTitle()
              return this.bookTitle;
         public String getAuthor()
              return this.author;
         public double getPrice()
              return this.price;
    }//close class

    page will only reload showing 20% of the content.Im building some carts too and I had a similiar problem getting null values from the mysql database. Are you getting null values or are they just not showing up or what?
    On one of the carts I'm building I have a similiar class to yours called products that I cast onto a hashmap works alot better. Mine looks like this, maybe this is no help I don't know.......
    public class Product {
        /**An Item that is for sale.*/
          private String productID = "Missing";
          private String categoryID = "Missing";
          private String modelNumber = "Missing";
          private String modelName = "Missing";
          private String productImage = "Missing";
          private double unitCost;
          private String description = "Missing";
          public Product( 
                           String productID,
                           String categoryID,
                           String modelNumber,
                           String modelName,
                           String productImage,
                           double unitCost,
                           String description) {
                           setProductID(productID);
                           setCategoryID(categoryID);
                           setModelNumber(modelNumber);
                           setModelName(modelName);
                           setProductImage(productImage);
                           setUnitCost(unitCost);
                           setDescription(description);        
          public String getProductID(){
             return(productID);
          private void setProductID(String productID){
             this.productID = productID;
          public String getCategoryID(){
             return(categoryID);
          private void setCategoryID(String categoryID){
             this.categoryID = categoryID;
          public String getModelNumber(){
             return(modelNumber);
          private void setModelNumber(String modelNumber){
             this.modelNumber = modelNumber;
          public String getModelName(){
             return(modelName);
          private void setModelName(String modelName){
             this.modelName = modelName;
          public String getProductImage(){
             return(productImage);
          private void setProductImage(String productImage){
             this.productImage = productImage;
          public double getUnitCost(){
              return(unitCost);
          private void setUnitCost(double unitCost){
              this.unitCost = unitCost;
          public String getDescription(){
              return(description);
          private void setDescription(String description){
              this.description = description;

  • Help needed in shopping cart implementation in JSP

    hi all,
    i need some help or code in implementing a shopping cart in JSP. Please send me code or any web resource.

    Hi!..i m in the same problem..if you have some idea or code..plz..
    robin_caba(@) yahoo.es

  • Need Help Badly on Shopping Cart Using JSP And Java Servlet

    Hi All,
    This is the 1st time i am trying to create a shopping cart using JSP and Servlet.
    I have read through a few acticles but i still do not get the whole idea of how it works.
    Please guide me as i need help very badly.
    Thanks.
    This is one of the jsp page which displays the category of products user would like to buy : Products.jsp
    <html>
    <head>
    <title>Purchase Order</title>
    </head>
    <body topmargin="30">
    <table border="0" width="100%" id="table1" cellpadding="2">
         <tr>
              <td bgcolor="#990000" width="96">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
              Code</font></b></td>
              <td bgcolor="#990000" width="260">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
              Description </font></b></td>
              <td bgcolor="#990000" width="130">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Brand
              </font></b></td>
              <td bgcolor="#990000" width="146">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">UOM
              </font></b></td>
              <td bgcolor="#990000" width="57">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Unit<br>
              Price </font></b></td>
              <td bgcolor="#990000" width="62">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
              Carton<br>
              Price </font></b></td>
              <td bgcolor="#990000" width="36">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
              Qty</font></b></td>
              <td bgcolor="#990000" width="65">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Add<br>
              To Cart</font></b></td>
         </tr>
    <tr>
    <td align="center" width="96" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">123</font>
    </td>
    <td align="center" width="260" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">Tom Yam</font>
    </td>
    <td align="center" width="130" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">Nissin</font>
    </td>
    <td align="center" width="146" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">12 x 10's</font>
    </td>
    <td align="center" width="57" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">$3.85</font>
    </td>
    <td align="center" width="62" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">$46.2</font>
    </td>
    <td align="center" width="36" bgcolor="#CCCCCC">
    <!--webbot bot="Validation" S-Data-Type="Integer" S-Number-Separators="x" -->
    <p align="center"><input type="Integer" name="Q10005" size="1"></p>
    </td>
    <td align="center" width="65" bgcolor="#CCCCCC">
    <p><input type="checkbox" name="checkbox" value="123"></p>
    </tr>
    <tr>
    </table>
    <table border="0" width="100%" id="table2">
         <tr>
              <td>
              <div align="right">          
                   <input type="hidden" name="hAction" value="AddToCart"/> 
              <input type=submit name="submit" value="Add To Cart"/>                     
    </div>
    </td>
         </tr>
    </table>
    </body>
    </html>
    After user has make his selection by entering the qty and ticking on the check box, he would click the "Add To Cart" button ... and this would call my servlet : AddToAddControlSerlvet.java
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.*;
    import java.util.*;
    import java.util.ArrayList;
    public class AddToCartControlServlet extends HttpServlet
         public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException
              String action = req.getParameter("hAction");
              if (action.equals("AddToCart"))
                   addToCart(req,res);
         public void addToCart(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
              try
                   String url = "";
                   String[] addList = req.getParameterValues("checkbox");
                   HttpSession sess = req.getSession(true);
                   //String sessionID = sess.getId();
                   DBClass dbClass = new DBClass();
                   ArrayList cartList = new ArrayList();
                   for (int i = 0; i < addList.length; i++)
                        String productCode = (String)addList;
                        int qty = Integer.parseInt(req.getParameter("Q"+productCode));
                        Products product = dbClass.getProductDetail(productCode);
                        double totalUnitAmt = qty * product.getUnitPrice();
                        double totalCartonAmt = qty * product.getCartonPrice();
                        Order order = new Order(product.getProductCode(),product.getProductDesc(),product.getBrandName(),product.getUom(),qty,product.getUnitPrice(),product.getCartonPrice(),totalUnitAmt,totalCartonAmt);
                        cartList.add(order);
                   sess.setAttribute("cartList", cartList);
                   url = "/Cart/CartDetails.jsp";
                   ServletContext sc = getServletContext();
                   RequestDispatcher rd = sc.getRequestDispatcher(url);
                   rd.forward(req, res);
              catch (Exception e)
                   System.out.println(e);
    From here, i would get the list of items which user has selected and add to the cartList, then i would direct the user to CartDetails.jsp which displayed the items user has selected.
    From there, user would be able to remove or to continue shopping by selecting other category.
    How i do store all the items user has selected ... everytime he would wan to view his cart ...
    As i would be calling from jsp to servlet .. or jsp to servlet ... and i do not know how i should go about in creating the shopping cart.

    Hi !
    Yon can use a data structure as vector and store the items selected by the user into the vector . Keep the vector in session using session object , so the user can access the entire shopping cart from anywhere in the application .
    Then , you can change the cart accordingly .
    Hope this works.
    Cheers ,
    Pranav

  • Need help in designing a shopping cart mall

    Hi guys,
    Can any one help out me in designing the shopping cart mall in servlets, jsp and oracle database. If so reply to me at this id "[email protected]"
    Thanks and Regards
    Madhu Kiran
    9866764834

    MadhuKiran wrote:
    Hi guys,
    Can any one help out me in designing the shopping cart mall in servlets, jsp and oracle database. Nope. And nobody wants to. That's because a few million have already been designed and you're likely not going to improve upon existing shopping cart technology.
    If so reply to me at this id "[email protected]"
    I hope you're prepared for lots and lots of spam!
    Thanks and Regards
    Madhu Kiran
    9866764834Is that your phone number? OMG did you really just post your phone number?! If so, I think that's a first.

  • I need  a simple example of shopping cart(newbie)

    Has any one come across a simple example of shopping cart and the process
    behind it i.e. from jsp to ejb. So far I have looked at the buybeans example
    and it still is not clear the approach that was used.
    I would be greatful for any assistance thank you
    Kenneth A-Adjei

    Take a look at:
    http://java.sun.com/docs/books/tutorial/servlets/overview/example.html
    "Ken Adjei" <[email protected]> wrote in message
    news:3960a901$[email protected]..
    Has any one come across a simple example of shopping cart and the process
    behind it i.e. from jsp to ejb. So far I have looked at the buybeansexample
    and it still is not clear the approach that was used.
    I would be greatful for any assistance thank you
    Kenneth A-Adjei

  • I want to add radio button selected value in shopping cart

    hi
    i am new to java
    and i am doing shopping cart project
    and i want to aad radio button selected value in cart but only one value.
    i am doing that in jsp.
    when iam adding that value the name of radio button is printed.
    and in remove page nothing displyed
    pls help me
    Thanks in advance.
    my code is-
    index.jsp
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    <html>
    <head>
    <title>Shopping cart</title>
    <style>
    * { font-size: 12px; font-family: Verdana }
    input { border: 1px solid #ccc }
    </style>
    </head>
    <body>
    <jsp:declaration>
    java.util.Enumeration parms;
    java.util.Enumeration values;
    </jsp:declaration>
    <jsp:scriptlet>
    parms = request.getParameterNames();
    values = request.getParameterNames();
    while(parms.hasMoreElements()) {
    String name = (String) parms.nextElement();
    String value = (String) values.nextElement();
    session.setAttribute(name, value);
    </jsp:scriptlet>
    <img src="images/add.png" onclick="document.location='index.jsp'">
    <img src="images/remove.png" onclick="document.location='remove.jsp'">
    <img src="images/cart.png" onclick="document.location='cart.jsp'">
    <h2>Add to shopping cart</h2>
    <form method="POST" action="index.jsp">
    <table>
    <tr>
    <td><input type="radio" name="radio" value="$10.00" checked></td>
    <td>$10.00</td>
    </tr>
    <tr>
    <td><input type="radio" name="radio" value="$15.00"></td>
    <td>$15.00</td>
    </tr>
    <tr>
    <td><input type="radio" name="radio" value="$20.00"></td>
    <td>$20.00</td>
    </tr>
    <tr>
    <td><input type="radio" name="radio" value="$25.00"></td>
    <td>$25.00</td>
    </tr>
    <tr>
    <td><input type="radio" name="radio" value="$30.00"></td>
    <td>$30.00</td>
    </tr>
    <tr>
    <td><input type="radio" name="radio" value="$35.00"></td>
    <td>$35.00</td>
    </tr>
    </table>
    <br><br>
    <input type="submit" value="submit">
    </form>
    </body>
    </html>
    cart.jsp
    <html>
    <head>
    <title>Shopping cart</title>
    <style>
    * { font-size: 12px; font-family: Verdana }
    </style>
    </head>
    <body>
    <jsp:declaration>
    java.util.Enumeration parms;
    </jsp:declaration>
    <img src="images/add.png" onclick="document.location='index.jsp'">
    <img src="images/remove.png" onclick="document.location='remove.jsp'">
    <img src="images/cart.png" onclick="document.location='cart.jsp'">
    <h2>The shopping cart</h2>
    <jsp:scriptlet><![CDATA[
    java.util.Enumeration content = session.getAttributeNames();
    while (content.hasMoreElements()) {
        out.println(content.nextElement());
        out.println("<br>");
    ]]></jsp:scriptlet>
    </body>
    </html>
    remove.jsp
    <html>
    <head>
    <title>Shopping cart</title>
    <style>
    * { font-size: 12px; font-family: Verdana }
    input { border: 1px solid #ccc }
    </style>
    </head>
    <body>
    <jsp:declaration>
    java.util.Enumeration parms;
    </jsp:declaration>
    <jsp:scriptlet>
    parms = request.getParameterNames();
    while(parms.hasMoreElements()) {
    String name = (String) parms.nextElement();
    session.removeAttribute(name);
    </jsp:scriptlet>
    <img src="images/add.png" onclick="document.location='index.jsp'">
    <img src="images/remove.png" onclick="document.location='remove.jsp'">
    <img src="images/cart.png" onclick="document.location='cart.jsp'">
    <h2>Remove items from cart</h2>
    <form method="get" action="remove.jsp">
    <table>
    <% if (session.getAttribute("$10.00") != null) { %>
    <tr>
    <td><input type="radio" name="radio"></td><td>$10.00</td>
    </tr>
    <% } %>
    <% if (session.getAttribute("$15.00") != null) { %>
    <tr>
    <td><input type="radio" name="radio"></td><td>$15.00</td>
    </tr>
    <% } %>
    <% if (session.getAttribute("$20.00") != null) { %>
    <tr>
    <td><input type="radio" name="radio"></td><td>$20.00</td>
    </tr>
    <% } %>
    <% if (session.getAttribute("$25.00") != null) { %>
    <tr>
    <td><input type="radio" name="radio"></td><td>$25.00</td>
    </tr>
    <% } %>
    <% if (session.getAttribute("$30.00") != null) { %>
    <tr>
    <td><input type="radio" name="radio"></td><td>$30.00</td>
    </tr>
    <% } %>
    <% if (session.getAttribute("$35.00") != null) { %>
    <tr>
    <td><input type="radio" name="radio"></td><td>$35.00</td>
    </tr>
    <% } %>
    </table>
    <br><br>
    <input type="submit" value="submit">
    </form>
    </body>
    </html>

    i used this where park .visits is the java class for
    visit object that contains getResort() method
    now error has gone but nothing is stored in the
    actionform class I would take that to mean the List
    1. does not contain a collection of Visit. You can check that by printing some debug statements inside the loop
    2. contains collection of visit objects. However the visit objects return null for getResort().
    Why dont you debug by printing out the objects from wherever you sit it in request/session scop (i.e in your servlet/web-handler)
    ram.

  • MVC - Planning A Shopping Cart..?

    Hi...
    I've been studying computer science at uni. for one academic year now... I've got experience working with Java, JSPs, servlets, JDBC, MVC architecture, SQL, web forms, sessions, etc. and I've put together a couple of reasonable web application projects.
    Over the summer, I'm hoping to practice my skills some more and make a web application which includes a shopping cart. I'm sure I have all the 'tools' I need to complete the task, but I'm not quite sure how to go about it (or if my ideas about how to go about it are right). I've already searched Google and these forums for tips, but I can't find the kind of high-level overview I'm looking for.
    So... I'm hoping someone can basically point me in the right direction in a top-down kind of way. I'll do the hard work by myself (or at least I'll try).
    I'm kind of guessing part of the structure might look something like the following, for a basic implementation...
    *SQL Database -
    Contains, amongst other things, a table of products which have IDs, names, descriptions, stock counts and prices.
    *Model -
    A Product class, which has the same fields mentioned above
    A ProductList class - a class which populates Product objects from the DB via JDBC
    A ShoppingCart class (which I'm probably imagining to be too simple) which can store Product objects (in an ArrayList field or something?). It would also contain getProduct / addProduct / removeProduct / getPriceTotal methods.
    *How it might work.
    The customer would browse products via the JSPs, and add / remove Products to the ShoppingCart via methods invoked in the controller. The contents of the cart would be saved via sessions.
    At the end of shopping, the customer would click Check Out and be taken to a page which shows the final contents and price of the cart. If the click proceed, they would be taken to some sort of secure payment portal (which would take the price from the getPriceTotal method..?) to make the payment... And then the order would be committed to the database for records..? I haven't really thought about payment yet...
    Thinking about it, a standalone program could be written for the site owner to bring up a list of most recent orders that are yet to be dispatched, from a table in the database. When dispatched, the entry could be removed from this table and added to another table of order history or something. This could be extended to include a GUI etc.
    Obviously, for security, all user input would be 'validated' by stripping any non-alphanumerical characters to protect the database and prevent SQL injections etc.
    Does any of that sound along the right lines..? If not, what else should I explore..? I appreciate that there are existing solutions, but that's true of almost every problem. I'd like to gain the experience of completing the project. Am I overlooking anything major..? What else could go wrong..? Should I explore any other security issues?
    Thanks in advance,
    Tom

    Dietrich wrote:
    Hi...
    I've been studying computer science at uni. for one academic year now... I've got experience working with Java, JSPs, servlets, JDBC, MVC architecture, SQL, web forms, sessions, etc. and I've put together a couple of reasonable web application projects.
    Over the summer, I'm hoping to practice my skills some more and make a web application which includes a shopping cart. I'm sure I have all the 'tools' I need to complete the task, but I'm not quite sure how to go about it (or if my ideas about how to go about it are right). I've already searched Google and these forums for tips, but I can't find the kind of high-level overview I'm looking for.
    So... I'm hoping someone can basically point me in the right direction in a top-down kind of way. I'll do the hard work by myself (or at least I'll try).
    I'm kind of guessing part of the structure might look something like the following, for a basic implementation...
    *SQL Database -
    Contains, amongst other things, a table of products which have IDs, names, descriptions, stock counts and prices.Yes, the product catalog. "Other things" would be customers, addresses for shipping, etc.
    *Model -
    A Product class, which has the same fields mentioned above
    A ProductList class - a class which populates Product objects from the DB via JDBCI'd call it the Catalog.
    A Customer might have a shopping history ("If you liked X, you might also like Y").
    I'd recommend that you start with the objects and let the database and UI follow from that.
    A ShoppingCart class (which I'm probably imagining to be too simple) which can store Product objects (in an ArrayList field or something?). It would also contain getProduct / addProduct / removeProduct / getPriceTotal methods.A data structure of some kind. A List or Map, yes.
    *How it might work.
    The customer would browse products via the JSPs, and add / remove Products to the ShoppingCart via methods invoked in the controller. The contents of the cart would be saved via sessions.
    At the end of shopping, the customer would click Check Out and be taken to a page which shows the final contents and price of the cart. If the click proceed, they would be taken to some sort of secure payment portal (which would take the price from the getPriceTotal method..?) to make the payment... And then the order would be committed to the database for records..? I haven't really thought about payment yet...Think it through. You're making a good start.
    Make that PaymentService an interface so you can switch the implementation.
    Thinking about it, a standalone program could be written for the site owner to bring up a list of most recent orders that are yet to be dispatched, from a table in the database. When dispatched, the entry could be removed from this table and added to another table of order history or something. This could be extended to include a GUI etc.
    Obviously, for security, all user input would be 'validated' by stripping any non-alphanumerical characters to protect the database and prevent SQL injections etc.Certainly you should do client and server side validation, but the real way to prevent the possibility of SQL injections is to not expose the database to the UI at all - and to use PreparedStatements to bind variables. Only a Microsoft nut would have bare SQL in the UI in the first place.
    Does any of that sound along the right lines..? If not, what else should I explore..? I appreciate that there are existing solutions, but that's true of almost every problem. I'd like to gain the experience of completing the project. Am I overlooking anything major..? What else could go wrong..? Should I explore any other security issues?Think about other roles besides customers. Who else could use this site? Admins? How does their functionality differ from Customers?
    Learn Spring: http://www.springframework.org
    %

  • Iterating shopping cart and extracting a list depending on condition

    Hi I am a newbie to ATG and coding world. Please help to resolve this issue:
    i need to iterate through my shopping cart and eliminate certain products from the shopping cart and create a new list of remaining items.
    Below is my code:
    <%@ page import="java.util.List,
    java.util.ArrayList"%>
    <dsp:droplet name="/atg/dynamo/droplet/ForEach">
                             <dsp:param name="array" bean="ShoppingCart.current.commerceItems" />
                             <dsp:setvalue param="myitem" paramvalue="element"/>
                                  <dsp:oparam name="output">
                   <dsp:getvalueof id="prdId" param="myitem.auxiliaryData.productId" idtype="java.lang.String">
                                       if (!(prdId.equals("xyz") || prdId.equals("abc"))) {
                                            mylist.add(myitem);
                                       %>
                   </dsp:getvalueof>
                   </dsp:oparam>
                   </dsp:droplet>
    now this statement myList.add(myItem) is giving me errors. Please help me resolve.
    TIA
    Edited by: user1762875 on Jun 6, 2013 5:54 PM

    I think rather than doing this in jsp you should be doing this task of removing items in Java code.
    There is a method removeItemFromOrder() in CartModifierFormHandler for removing items in Order and you should be invoking that. For items to be removed just add the sku id's in pRemovalCommerceIds array of CartModifierFormhandler and invoke method.
    you can do this addition in the If block of your code and at the end if there is something in list you can invoke the method
    Thanks

  • Shopping cart in portal 8.1

    Folks,
    How do I create a shopping cart in WebLogic portal 8.1? Is there any ready made
    template available?
    Thanks
    Johnson

    There currently aren't any samples or template JSPs that use commerce in
    8.1.
    The 7.0 version of WLP included wlcsDomain and wlcsApp, which was a
    commerce sample that had sample shopping cart code. However, most of
    that code in encapsulated in 7.0 PipelineComponents, which are
    deprecated in 8.1. You can look at the code in there
    (bea/weblogic700/samples/portal/wlcsDomain/beaApps/wlcsApp/src in
    examples/wlcs/sampelapp/shoppingcart) for how to manipulate a shopping
    cart. Additionally, the wlcs webapp has code and jsps (in wlcsApp/wlcs
    and WEB-INF/src under that) you can look at. The APIs haven't changed
    significantly between 7.0 and 8.1.
    Greg
    Johnson wrote:
    Thanks, Greg.
    Is there any readymade JSP template comes with portal 8.1 to use? Or Do I need
    to design the shopping cart GUI?
    Gregory Smith <[email protected]> wrote:
    You can add the commerce class to your application by
    right-mouse-clicking on the appliation in Workshop and choosing
    Install|Commerce Services. This will basically give you commerce.jar,
    APP-INF/lib/commerce_util.jar, and replace wps-toolSupport.war with
    toolSupport.war. It's best to do this while your server is not running.
    Once you have that, you can access the
    com.beasys.commerce.ebusiness.shoppingcart classes. There are javadoc
    for those
    (http://edocs.bea.com/wlp/docs81/javadoc/com/beasys/commerce/ebusiness/shoppingcart/package-summary.html).
    You can also look at the 7.0 and 4.0 docs for portal, which contain
    information about using the commerce classes (although webflow and
    pipeline are gone, the base commerce classes haven't significantly changed).
    Greg
    Johnson wrote:
    Folks,
    How do I create a shopping cart in WebLogic portal 8.1? Is there anyready made
    template available?
    Thanks
    Johnson

  • An Online Shopping Cart

    I need an online shopping cart (Professional) which is made in JSP technology..
    Thanks

    I've written an entire jsp/servlet ecommerce system.. what do you need it for ?
    Other options.. check out the jakarta Duke Book Store examples and there is something called jshop on the web somewhere too.

Maybe you are looking for

  • Tivo disc to iMovie???

    A friend of mine recorded a show from TIVO onto a DVD. I would like to be able to edit part of that show in imovie. Does anyone know how I can convert the TIVO file into something compatible for editing in imovie? Thanks!

  • ISE Posture Discovery option missing in Auth Profiles

    Hi all. I have been working off the following document but am having problems finding the "Posture Discovery" option in the Authorization Profiles. http://www.cisco.com/en/US/products/ps10315/products_tech_note09186a0080bba10d.shtml The device has tr

  • Help in TKPROF Output: Row Source Operation v.s Execution plan confusing

    Hello, Working with oracle 10g/widnows, and trying to understand from the TKPROF what is the purpose of the "Row Source operation" section. From the "Row Source Operation" section the PMS_ROOM table is showing 16 rows selected, and accessed by an ACC

  • Use of table for field names

    hi guru's is there any way to check the table if i am having the data elements. i am having some data elements or field name, i just wanted to know, what are all the table which are using this fields. se16 is for checking the table, but i want to che

  • Is there a way to revoke DDL privileges from a user

    I would like to revoke DDL privileges from a user. My requirement goes like this 1.Create a user with DDL privileges 2. Create the required tables in that user. Fill the data. 3. Revoke DDL privileges from that user (CREATE,ALTER,DROP). I was able to