advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement

JavaBoutique : Articles : Open Source Shopping Cart:

Contents
Introduction
Persistence: Method 1
Functionality
Persistence: Method 2
Illustration: Example 1: Applets
Illustration: Example 2: Active X
Illustration: Example 3: Pseudo-Constructor
The Code
Extended Examples
Shopping Cart and Database
Checkout
Multiple Merchants
Conclusion
Addendum: Mac Version and Back End Progress

Conclusion

The coding challenge was to find some way to distinguish the companies, all of which now resided on the same server, and thus had the same applet codeBase. I chose to have the applet read the documentBase for the particular HTML page, and to snip out the portion which represented the merchant's particular root directory. No matter what sub-directory the browser was in, the portion at the beginning of the http:// address, up to and including the root for that merchant, would always be the same. The first applet parameter, named "start," told the applet where to begin snipping. The second, named "value," told it where to stop. For instance, if the merchant address was http://www.infinitestores.com/oneMerchant, "start" in the zero-based count would be 29, and length would be 11. This would snip out the string "oneMerchant," and ShopPanel could then place it in the slot reserved in the small business version for shippingAndHandling.

Every merchant would call the same applet, preferably using a CODEBASE=http://www.absoluteAddressOnServer call (for an example, view the source at http://209.87.142.42/is1). The fact that the absolute call was for an applet on the same server as the document would ensure HTML memory. However, an absolute call would mean that there would be no need to keep track of directories and sub-directories. This could be important on a large site with multiple servers. Every time the applet was reactivated on some page, it would reload the parameters from that particular HTML page, and if these were different from those in some other reactivation on another page, the values would be modified. Merchants could thus be distinguished.

The company director told me that, in his experience, many orders were canceled at checkout when buyers realized the full impact of shipping and handling. He wondered if it was possible to place a price in the cart that reflected the full cost of shipping and handling. I suggested that he include a call in ShopPanel to the appropriate database on his site, and update the price as desired. There would be an initial result, from numbers placed into the HTML (probably by his databases, perhaps using active server pages), and then a few moments later an update (taking account of volume discounts based on amount purchased, if applicable, and so on). Since JAVA is multi-threaded, and separate from HTML, this could take place simultaneously with other purchases, and independently of HTML page transfers. Since pseudo-constructors maintain the JAVA frame and code when off-site, it would not matter if the buyer jumped elsewhere in the middle of an update. With code size reduced to 13K, there was plenty of room.

Using this modified cart, the company could now handle both a multi-merchant cart, and small business carts. If the applet codebase in the checkout querystring was the company's site, then the company would know that the shippingAndHandling slot for each product provided the respective merchant's unique directory name, and interact with databases appropriately in order to finalize the order further. Alternatively, if the applet codebase was something different, then that codebase would be the merchant's identity - it would be unique because every http:// address is different. All aspects of a small business transaction would be automated - from initial sign-up, to database maintenance through an optional text file on the merchant's server, to shipping and handling calculations (according to coded instructions in the shippingAndHandling string for each product). Since there would be no need for personal communication, it would make economic sense to deal with the small merchant.

Everything would be interrupt driven: from JavaScript event handlers inserted into elements on an HTML page calling the applet to indicate a purchase; by the applet calling an appropriate database for information; or by the user finalizing an order and through this, sending a querystring to an order-handling section. Persistence would be maintained on the browser, freeing up central server resources, and ensuring a fast connection. There would be smooth interaction between merchants hosting on the same site, and those hosting on other servers.

The multi-merchant version of the cart at present retains the shippingAndHandling field in the HTML coding, even though this information is no longer needed by the multi-merchant site - shipping and handling would be handled through interaction with various databases. The fact that the HTML is unchanged allows a particular merchant to move back and forth easily from hosting at the Seattle company-- with the advantage of placing his orders on a single shopping cart with those of others-- to hosting elsewhere for less money, with the penalty of having his own cart. He does not have to make HTML modifications to his site. Class ShopPanel in the multi-merchant version in turn overrides any ShippingAndHandling information that it receives and instead passes on the merchant's directory string. The fact that the querystring format is unchanged in the multi-merchant version presumably should make things easier at the server end.

I look forward to seeing modifications that will be made by other Open Source developers, and implementations by various companies. I trust that competition will bring us quality service for a low price.

by Lane Friesen
lanelise@dowco.com
- June 2000


How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.

 Avaya Developer Showcase
 MSDN Spotlight
 PHP for Windows Showcase
XML error: undefined entity at line 34
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

IBM Brings Developers Into the Cloud
Apache at 10: You Can't Buy Us
Microsoft's CodePlex Foundation Moving Forward
Apple Claims 100,000 Apps, Google Analyzes Them
Nokia Latest to Play Opera Mobile 10 Browser
PayPal Opens Up Payment Platform to Devs
Ubuntu Linux 9.10 'Karmic Koala' Starts Its Climb
IBM Links Rational Developer Tools, Tivoli Apps
Libraries Give Vista Apps a Windows 7 Look
Ubuntu: The 'Default Alternative' to Windows?

Delivering Web-based Embedded Fonts in CSS 3
Adobe Helps PHP Developers Create Rich Internet Applications
Java Developers Finding a Home at Adobe Flex
Virtualization Delivers a Dynamic Infrastructure
Consuming XML Web Services in iPhone Applications
Build a More Agile Business with IBM
POJO-Based Solutions for LDAP Access: One Good, One Better
IBM Offers Enhanced Measurement and Management for Energy Usage
IBM Helps Transformation to an Information-Based Enterprise
Top Five Touch UI-Related Design Guidelines

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs