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 :

Cracking the HTML Persistence Barrier

Contents
Introduction
Intro pt 1
Intro pt 2
Intro pt 3
Intro pt 4
An Illustration of these Techniques
An Applet Example
An Active X Example
A Pseudo-Constructor Example
Pseudo-Constructor pt 2
Applet Persists Indefinitely; Breaks into JavaScript
Persistence
Conclusion

Now, what happens if the same applet (same name, same codebase) is loaded by two separate pages? An applet is identified only by its name and codebase. Thus, if a page loads an applet with the same name as one that was loaded by a previous page, and if this involves a relative (in contrast to an absolute) call to the same codebase, then the applet for the previous page becomes active again – just as if it had been called by the previous page. A new instance of the applet is not usually loaded. This feature is used by the shopping cart to store information between HTML pages. It works much better than cookies.

An applet, however, contains program code as well as variables. Thus, since it is a program that is being re- activated, persistent processing can be carried out on the persistent memory. A program can thus be written that appears to live on from page to page – all that is necessary is to reload the same code – when the user leaves the applet’s page, this exit alters the page’s applet from an active to an inactive state, and when the user enters a different page that reloads the previous applet through a relative call, this entry changes the applet back again to an active state which uses its previous memory. The new page, as part of the applet’s life cycle, calls the applet’s init() and start() methods; apart from that, applet program function picks up at the point where it left off on the previous page. If one desires to keep certain variables, then it is enough to declare them as static, and make sure they are linked to static entities – the garbage collector will then leave them alone.

If an applet with the same name but a different codebase is loaded, then, for security reasons, it is assigned a new address space. The same shopping cart code, even when it is run simultaneously on separate commercial sites from the same browser, can therefore develop and maintain distinct shopping carts for the separate merchants. JAVA security, which we exploit here to our advantage, takes care of all the details!

If an HTML document in a subdirectory of a site wishes to participate in the persistence, then it is sufficient to add the line CODEBASE=../ to the APPLET tag. This technique can be extended throughout a directory and subdirectory structure, so that persistence spreads freely throughout any given site.

Since Active X as implemented in Microsoft’s Dynamic HTML is based in the JAVA language, it turns out that it can also generate persistence. The said applet has in fact been successfully ported to an Active X object. The said ‘boilerplate code,’ in the previous section, may thus be altered so that it is an <OBJECT> that is loaded rather than an <APPLET>. With a few minor adjustments, there is the same functionality.

Next ->


Lane Friesen

lanelise@dowco.com

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.

 Microsoft Visual Studio 2010 Showcase
 Avaya Developer Showcase
 MSDN Spotlight
 PHP for Windows Showcase
XML error: undefined entity at line 39
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%.

Windows 7: From Beta to Final Code in One Year
Google Shows Off Chrome OS, Releases Source
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?
Fedora 12 Takes Aim at Linux Networking
Top Supercomputer Nearly Doubles in Speed
Fedora 12 Linux Tackles Virtualization
Apple Gives iPhone Developers App Status Tracker
Novell Sets OpenSUSE 11.2 Free

Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Exploring HTML 5's Audio/Video Multimedia Support
Overriding Virtual Functions? Use C++0x Attributes to Avoid Bugs.
Understanding the Cloud Computing Security Vulnerabilities
Cisco and IBM Target a Greener World
Upgrade to Visual Studio 2010 with the Ultimate Offer

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, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs