aspose file tools*
The moose likes Applets and the fly likes Applets and AJAX Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Applets and AJAX " Watch "Applets and AJAX " New topic
Author

Applets and AJAX

Joshy Thomas
Greenhorn

Joined: Jul 23, 2004
Posts: 13
I have created a Tax Calculator applet and is distributed FREE. But the issue is every year I need to re create the applet with new tax rules which is ok, but re distributing it to users is a hell and is not practical. I want to create a maintenance free applet for all users.

I am thinking whether I can use the Applet and AJAX together to achive the same. The applet to javascript communication in turn will make an AJAX call my server and in the reply will supply the varing parametes to the applet.
Is it a practical approach or any issues with it.

Joshy
Note: If you are interested, visit my 2006 Tax Calculator applet at
http://www.bestonlinetaxpreparation.com/2006TaxCalculator.html

[ April 24, 2006: Message edited by: bestonlinetaxpreparation.com ]
[ April 24, 2006: Message edited by: Joshy ]

<a href="http://www.FindTaxService.com" target="_blank" rel="nofollow">Free Tax Software</a>
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
Hello-

Welcome to JavaRanch.

On your way in you may have missed that JavaRanch has a policy on display names, and yours does not comply with it - please adjust it accordingly, which you can do right here. Thanks for your prompt attention to this matter.

Since your display name is advertising for your web site, you need to change it very quickly, or your account will be closed and the posts deleted.


Ping & DNS - updated with new look and Ping home screen widget
Joshy Thomas
Greenhorn

Joined: Jul 23, 2004
Posts: 13
Sorry about that.. Actually I did not read the name policy and thought let me little oversmart...

Joshy
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

The whole point of an applet is that it's downloaded from the Web server anew each time it's run; therefore I'm not following you on why you need to do anything special to update it.

For updateable applications, the standard solution is Java Web Start, which is a sort of sandboxed application host with applet-like download/upgrade features.

Don't reinvent the wheel!


[Jess in Action][AskingGoodQuestions]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
Hello Joshy-

Thanks for adjusting your screen anme, but you're not quite there. The policy requires a first name, a space character, and then a last name. Please adjust yours accordingly.
Joshy Thomas
Greenhorn

Joined: Jul 23, 2004
Posts: 13
OK.. OK..I feel the HORN now !!!....
Joshy Thomas
Greenhorn

Joined: Jul 23, 2004
Posts: 13
Hello Ernest Friedman,

Thank you for posting your comments. I created this applet http://www.bestonlinetaxpreparation.com/2006TaxCalculator.html to distribute it free (downloadable from most of the freeware sites) and any webmaster interested in displaying a 2006 Tax Calculator can use it in their website. The calculator is not a link to my site where applet is displayed; it is aimed at all tax related websites owned by tax professionals for their visitors.

Now to your point, the tax laws change every year and this applet will not work for 2007 tax year. The user of this applet needs to come back to me for 2007 version of applet or I have to trace them and re-distribute it again. I think it is lots of pain..with no gain..You can think of this as website operational problem. (((I just want their visitors to visit my site. not maintain their website..just kidding )).

So, I started thinking about a maintenance free applet.. If I can pass all tax law parameters in HTML parameters , It is possible to solve this problem, but webmasters need to edit their html and set the parameter values. The problem with approach is webmasters can mistake and calculator will display wrong results and it will damage the reputation of the calculator. Again I need to trace them. This approach is used by some of existing calculators including the commercial ones..

I don�t want to sign the applet as well.

I thought AJAX may be the answer to this problem. I can have some JavaScript in the applet html which will make the AJAX call to my web server and I will return the XML with the tax codes. The applet engine will parse this XML and do the tax calculation and display the results. This way once the applet is displayed in any website, webmasters need not worry about it.

This is my idea.. The problem is I am new to AJAX and hence I want to know whether it is a practical idea.. Anybody did something like this before. Issues of parsing an XML inside the applet..
[ April 27, 2006: Message edited by: Joshy Thomas ]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8713
    
    6

Originally posted by Joshy Thomas:
I can have some JavaScript in the applet html which will make the AJAX call to my web server and I will return the XML with the tax codes.


AJAX, in particular, the Javascript XMLHttpRequest method, is under the same restrictions as a Java applet. It may only make a request back to the server the page was downloaded from. So no, AJAX will not solve your problem.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Joshy Thomas
Greenhorn

Joined: Jul 23, 2004
Posts: 13
Thanks Joe,

Ok..I was under the IMPRESSION that AJAX is nothing but Javascript with XML data support. I just read the same from the book "Professional Ajax by Wrox". It is a nicely written one. So, AJAX will not solve my problem. Only option is to have a server proxy by having server side scripting, which calls my server. This is what I want to avoid. I feel it is asking too much to webmasters and they may prefer not to use the applet itself. I am not particular about the tools to use(javascript/ajax,....) , I need to solve this problem... Let me do some (re)search on Google to find out whether I can get any solution..

Thanks
everybody
[ April 28, 2006: Message edited by: Joshy Thomas ]
Ernesto Leyva
Ranch Hand

Joined: Feb 23, 2006
Posts: 62
Hello


...AJAX, in particular, the Javascript XMLHttpRequest method, is under the same restrictions as a Java applet. It may only make a request back to the server the page was downloaded from. So no, AJAX will not solve your problem....


You may want to check this property "document.domain = 'mydomain.com'"

We used the XMLHTTPRequest sometime ago and I remember at some point
we started getting security warnings that we solved using the property
above thru javascript when the html page was loaded. This worked for IE6
I am not sure for other browsers
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15292
    
    6

You can use Ajax to help solve this problem. Ajax is not limited to calling a single server. I can create some javascript that runs on my local PC and makes an Ajax call to google.com if I want to.

You could also just let the Applet make a URLConnection to your server and do the same thing when it loads. You'll just need to adjust the security constraints of the applet accordingly.
[ May 11, 2006: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8713
    
    6

The way I understand the problem, Joshy's applet would be downloaded from a third party web server (let's say www.joe.com) to a client's PC and make a check for updates from there to his web server (www.bestonlinetaxpreparation.com). That cannot be done:
When the XMLHttpRequest object operates within a browser, it adopts the same-domain security policies of typical JavaScript activity. . . the domain of the URL request destination must be the same as the one that serves up the page containing the script.

Dynamic Html and Xml: The XMLHttpRequest

As for Ernesto's suggestion, document.domain can be used to set a more general domain (i.e. example.com instead of www.example.com), but can't set a different domain (i.e. www.google.com instead of www.example.com). See Javascript Security for a more detailed explanation.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Applets and AJAX
 
Similar Threads
Site testing needed for Ajax system
From Christian Gross: Summary of topics from Feb 21 to Feb 24
Making Java GUI code open source?
Applet not initialising
Does ghost exist?