• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

can anyone help me to construct my on-line store

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'd like to construct a on-line store program by using Java servlet/JSP. Can anyone give me some good website on how to construct it step by step? Or is there any good sample code on-line?
Thanks a lot!
 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

I would first suggest that you go to one of the online stores and take a look at the behaviour of their shopping carts. I tried www.amazon.com and www.buycds.com and I liked what I saw.

Here is what i believe you need:

1. A JavaBean which will act as your ShoppingCart Object
2. A database to hold your products
3. A Servlet to act as a controller (e.g. a view could call the servlet when adding/removing items from your cart
4. A JSP which can act as a 'View'. This jsp will allow you see the current state of the cart.
5. 1 or more jsps which will allow you to interact with the servlet (see point 3).

Here is how it all works:

This is called MVC.

You have a jsp that gets the items from your db and displays them on a table. You provide a link on this table which also embeds information such as productId etc so that you can forward this information to other pages. Call this jsp something like 'AddToShoppingCart.jsp'

When you click the 'Add' button on the 'AddToShoppingCart.jsp' it will then forward all the data to the 'ShoppingCartControllerServlet.java' file

The 'ShoppingCartControllerServlet.java' file merely takes the commands like 'add, remove or updateQuantity' from any of the jsps and processes them by calling the ShoppingCart class/Object. After it has done it's job it should automatically forward you back to the view (viewShoppingCart.jsp) so you can see the state of your cart.

The viewShoppingCart.jsp could use a nicely formatted table to display your cart and have buttons such as 'remove' or updateQuantity.

Well, that was just a brief explanation to give you an idea. There are a lot more issues involved here like making sure that you keep a ShoppingCart object in a session while the user is still shopping so that things don't get mixed up. You then have to allow the user to check-out like in a normal shop and not to mention the credit card handling mechanism.

I have done this for myself just out of curiosity and i would be happy to show you some of my code.

Good luck!!
[This message has been edited by ernest fakudze (edited October 15, 2001).]
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use Struts as the application framework to make things a little easier for you if you want http://jakarta.apache.org/struts/
Keep your eye on MyCart http://mycart.cjb.net/ because they might actually get it done one day.
Or check out this article: http://www.java-pro.com/upload/free/features/javapro/2000/06jun00/gb0006/gb0006.asp
Plus you can have a look at the Java Pet Store from Sun (look up the URL your self!) which illustrates what they think are "best practices" for J2EE applications. However, this might be overkill for what you want since it uses EJB's which aren't really neccessary for small scale developments amongst other things.
And of course there is google.com which will find you about a million other examples if you ask it nicely.
Andre.
 
david hu
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to all of you!!!
All you suggestions are very helpful to me!
David
 
reply
    Bookmark Topic Watch Topic
  • New Topic