Java AJAX vs JAVA: A Comparison of Web Development Languages

  • Thread starter Thread starter Ulysees
  • Start date Start date
  • Tags Tags
    Java
AI Thread Summary
AJAX is a technique that uses JavaScript and XML to provide instantaneous responses to user inputs without reloading the page, while Java is a programming language that can be used for server-side applications. AJAX is often seen as more efficient for web applications due to its ability to handle user interactions quickly, whereas Java applets can be resource-intensive and require plugins. Both technologies can be used together to enhance web applications, allowing Java to handle server-side logic while AJAX manages client-side interactions. However, Java's server-side components, like JSP, do not update instantly without AJAX. The discussion emphasizes that while AJAX and Java serve different purposes, they can complement each other in web development.
Ulysees
Messages
515
Reaction score
0
Which one is better?

It turns out that AJAX suffers from the fact that 90% of development time is spent trying to work around intricacies of specific platforms, which is why google came up with a library that converts JAVA applets into AJAX code.

But why not stick with JAVA anyway? Can't JAVA produce a site that looks like this forum? Can't it provide all the same functionality but in different code, and much more responsively?
 
Technology news on Phys.org
You can use both together. You could certainly build a system like PF with JAVA (JSP...J2EE). AJAX is a technique rather than it's own language. The technique utilizes XML and Javascript to process a user request immediately instead of having to refresh the page. So yes you can use JAVA and AJAX together to create a system like PF.

Google likely created a library to convert applets to javascript because applets are resource hogs, have poor usability and need plugins to operate. Javascript is platform independant as well.
 
Last edited:
I think JAVA would much slower than AJAX for creating a forum like PF. Much slower. HTML loades much faster than a JAVA applet. But I guess applets could be designed to load faster.AJ
 
ajsingh said:
I think JAVA would much slower than AJAX for creating a forum like PF. Much slower. HTML loades much faster than a JAVA applet. But I guess applets could be designed to load faster.

It's a different way of doing things, AJAX downloads first a lot and then interacts instantaneously, like FLASH. JAVA has the same philosopy by default.

But all JAVA applets I've seen look like FLASH graphics or windows dialog boxes, not browser text.

Anyone know if browsable forum text can be done with JAVA?
 
Ulysees said:
It's a different way of doing things, AJAX downloads first a lot and then interacts instantaneously, like FLASH. JAVA has the same philosopy by default.

But all JAVA applets I've seen look like FLASH graphics or windows dialog boxes, not browser text.

Anyone know if browsable forum text can be done with JAVA?

Ulysees, did you read my post at all? You are really confused and I suggest you do some research on the technologies in general. You can't compare AJAX and JAVA. They are apples and oranges. But you can use them together to make a great smoothie :smile:. JAVA is a programming language. AJAX is a programming technique that uses javascript and xml. You can build a forum with JAVA with AJAX techniques, but you can't build a forum with just AJAX (javascript and xml).

If you want to use an applet then yes it is fairly similar to flash. However you can easily use JAVA in the form of JSP, which is comparable to PHP, ASP, ROR, CF...
 
Last edited:
Greg Bernhardt said:
Ulysees, did you read my post at all? You are really confused and I suggest you do some research on the technologies in general. You can't compare AJAX and JAVA.

Tell that to a customer who wants to offer a geographical system like google maps. It could be done, for example:

- As many pictures that are shown when you click on links in HTML

- As a WIN32 application that downloads maps into memory and shows the bit you're looking at.

Is customer allowed to compare WIN32 with plain HTML or is it apples with oranges?

I am aware of the philosophy of AJAX, which is all about using standard web things like javascript xml and asp in a way that gives instantaneous response from user input.

JAVA, I've only used as a substitute for C++ in desktop applcations, so I wonder if it can control the display of text in a browser like javascript does, that's my question.

> If you want to use an applet then yes it is fairly similar to flash. However you can easily use JAVA in the form of JSP, which is comparable to PHP, ASP, ROR, CF...

Not sure what this parade of acronyms is saying to its users, but for me, does JSP look like physicsforums.com?

Does JSP respond instantaneously, ie you get from the server all new forum posts and show the user the topics he clicks on instantaneously?

In fact I wanted to design forum software like this. It would be super-responsive, it would be held on member's local hard disks, members would be able to ignore certain categories, etc.
 
AJAX can be compared to (client-side) Java applets or to server-side Java like J2EE. Server-side Java can be used with AJAX, or a Java applet can transfer data to a server with XML (though not AJAX per se), but that's about it.
 
Ulysees said:
I am aware of the philosophy of AJAX, which is all about using standard web things like javascript xml and asp in a way that gives instantaneous response from user input.

JAVA, I've only used as a substitute for C++ in desktop applcations, so I wonder if it can control the display of text in a browser like javascript does, that's my question.

> If you want to use an applet then yes it is fairly similar to flash. However you can easily use JAVA in the form of JSP, which is comparable to PHP, ASP, ROR, CF...

Not sure what this parade of acronyms is saying to its users, but for me, does JSP look like physicsforums.com?

Does JSP respond instantaneously, ie you get from the server all new forum posts and show the user the topics he clicks on instantaneously?

It's important you mention ASP. ASP is what you can compare to JAVA (JSP) not AJAX. You can use both ASP or JSP in conjunction with AJAX. AJAX is a client side technique (meaning you can't push data to a user) to run ASP or JSP scripts without having the user reload the page. And yes you could create a site just like PF using JSP. But since JSP is server side it will not update instantly. But you can use JSP with AJAX to update instantly. Understand?
 
Greg Bernhardt said:
It's important you mention ASP. ASP is what you can compare to JAVA (JSP) not AJAX. You can use both ASP or JSP in conjunction with AJAX. AJAX is a client side technique (meaning you can't push data to a user) to run ASP or JSP scripts without having the user reload the page. And yes you could create a site just like PF using JSP. But since JSP is server side it will not update instantly. But you can use JSP with AJAX to update instantly. Understand?

You mention JSP scripts. Is JSP an acronym for javascript? If yes, then it's not suitable for what I want, because I want a super-responsive version of physicsforums where you only download new posts, but javascript cannot save data onto hard disk. So you'd have to reload too much every time you go to the site, in order to have fast interactive access to all topics. So what I want is like an email client for forums posts, that displays forum posts on web format.
 
  • #10
Ulysees said:
You mention JSP scripts. Is JSP an acronym for javascript? If yes, then it's not suitable for what I want, because I want a super-responsive version of physicsforums where you only download new posts, but javascript cannot save data onto hard disk. So you'd have to reload too much every time you go to the site, in order to have fast interactive access to all topics. So what I want is like an email client for forums posts, that displays forum posts on web format.

I see now. JSP is "Java Server Pages" and is equivalent to ASP but in Java scripting form. You're better off using a language for client application development (C++, JAVA,VB ). AJAX is Javascript btw. So in conclusion you could still use AJAX with your application development, but it still needs a server side component. So you could develop an application using JAVA, JSP and AJAX together. But now that I'm thinking, you could prolly just use regular client JAVA functions, you don't need JSP or AJAX.
 
Last edited:
  • #11
> So in conclusion you could still use AJAX with your application development, but it still needs a server side component

How will I save messages onto client hard disk?
 
  • #12
Ulysees said:
> So in conclusion you could still use AJAX with your application development, but it still needs a server side component

How will I save messages onto client hard disk?

You'll have to read up on the JAVA functions. I'm sure there is a function for saving data onto the hard drive or atleast reading from an online database.
 
  • #13
I tried this with javascript once, and it didn't exist, "for security reasons". Java applets, probably have the same problem, and they don't look like physicsforum.com, they look like flash.

Can't believe it is so hard to save on disk on the client side. There's got to be a way.
 
  • #14
Ulysees said:
I tried this with javascript once, and it didn't exist, "for security reasons". Java applets, probably have the same problem, and they don't look like physicsforum.com, they look like flash.

Can't believe it is so hard to save on disk on the client side. There's got to be a way.

Right, Javascript does not have this capability. You should look into stand-alone java programming if you don't want an applet.
 
  • #15
Well the whole idea is something that works without users installing anything, just use their browser, and enjoy interactivity like that of googlemaps. Googlemaps reloads maps every time you visit, my forum has to only load each piece of data once and save it to disk (or cache?)
 
  • #16
Remember JSP, ASP, PHP, all of these are what they call stateless connections. Java runs in it's JVM and can maintain state with the server, the others must make round trips to the server. To "save messages" your going to have to maintain somesort of state on the client machine. Cookies are a way, or have the server maintain a message read/not read list for each unique user. This is one of the biggest pains with web technologies. With a java applet running inside a JVM your essentially running a stand alone, statefull application that can interact with the server, and the client file system just like any other W32 app.
 
  • #17
How much data can I save in cookies?
 
  • #18
I don't believe there is any real limit, I could be wrong, but remember a cookie is only a text file. You would have to parse the thing with somesort of delimiter to substitute for a table. If the forum was any kind of size this file would get huge fast. That's why they are normally only used to maintain user ID's and configuration data. The other alternative is for maintain this on the server's DB, which I do believe is how this forum tells what posts you've read, not read. Like I said, maintaining state is a huge pain and will get in the way of a lot of your "stand alone" application previous thinking.
 
  • #19
Ulysees said:
Well the whole idea is something that works without users installing anything, just use their browser, and enjoy interactivity like that of googlemaps. Googlemaps reloads maps every time you visit, my forum has to only load each piece of data once and save it to disk (or cache?)

Then you'll need either flash or a Java applet. Googlemaps works because it uses a server side language too. Not sure what it is, but PHP, ASP, JSP would all work just fine with AJAX. So you could use JSP and AJAX, but it wouldn't be able to save anything to disk directly. At most it would be a save file prompt.
 
Last edited:
  • #20
Ulysees said:
How much data can I save in cookies?

4k. Any larger and the IE ignores the write.
 
  • #21
Ulysees said:
Well the whole idea is something that works without users installing anything, just use their browser, and enjoy interactivity like that of googlemaps. Googlemaps reloads maps every time you visit, my forum has to only load each piece of data once and save it to disk (or cache?)

You should let the browser do most of the caching. You can set content expiration headers on the server side to inform the browser to use cached content.
 
  • #22
CRGreathouse said:
AJAX can be compared to (client-side) Java applets or to server-side Java like J2EE. Server-side Java can be used with AJAX, or a Java applet can transfer data to a server with XML (though not AJAX per se), but that's about it.

I wouldn't compare Ajax, or javascript, with Java because in terms of capabilities they're very far apart. Java applets can be granted full access to system resources, and perform any range of functions (including hardware manipulation). They're also completely different languages in orientation.
 
  • #23
Also Google created a translator between Java and Javascript, but it's not meant to be used to convert Java applets to Javascript - because you can't, javascript doesn't have sufficient capabilities. The goal is to be able to program javascript using Java, an Object Oriented language, and use the advantages therein.
 
  • #24
-Job- said:
You should let the browser do most of the caching. You can set content expiration headers on the server side to inform the browser to use cached content.

Is it possible to not ask the server at all, just get data straight from the cache? Because the main problem of the internet is delay, not download speed.
 
  • #25
-Job- said:
Java applets can be granted full access to system resources, and perform any range of functions (including hardware manipulation).

Hardware manipulation from java applets running in the browser? Or are you talking about stand-alone java? If java applets support hardware manipulation, then why can't we write to disk from them?

By the way. Do you know the function calls to access the microphone from a java applet running in the browser?
 
Last edited:
  • #26
Ulysees said:
Is it possible to not ask the server at all, just get data straight from the cache? Because the main problem of the internet is delay, not download speed.

How do you fill the cache and communicate what's in the cache without hitting the server at some point? Also, if you are working from cache, the information won't be up to date, especially for a community.

Ulysees said:
Hardware manipulation from java applets running in the browser? Or are you talking about stand-alone java? If java applets support hardware manipulation, then why can't we write to disk from them?

By the way. Do you know the function calls to access the microphone from a java applet running in the browser?
You can access hardware form an applet, but for most machines you'll need to get permissions, aka a security popup. Again an applet will be bulky and much like flash.

Try something like Microphone.get();
 
  • #27
-Job- said:
I wouldn't compare Ajax, or javascript, with Java because in terms of capabilities they're very far apart. Java applets can be granted full access to system resources, and perform any range of functions (including hardware manipulation). They're also completely different languages in orientation.

Oh sure, I agree completely -- but at that point in the thread it wasn't clear whether the original poster was asking for a client-side replacement (Java applet) or a server-side one (J2EE). My only purpose was to probe as politely as I could toward the purpose, since it's hard to coherently answer the question without understanding that point!
 
  • #28
>> Is it possible to not ask the server at all, just get data straight from the cache? Because the main problem of the internet is delay, not download speed.

> How do you fill the cache and communicate what's in the cache without hitting the server at some point?

Well you'd only want hit the the server once. With Microsoft Outlook, do you hit the server every time you read an email? No, you just hit it once every that many minutes, and then it's fully interactive. So it's a replacement for Outlook I'm trying to come up with. Except the user sees the forums in the browser in the form that they do now.

> You can access hardware form an applet, but for most machines you'll need to get permissions, aka a security popup.

Do you have any examples? A site I can visit that presents security popups of java applets doing fancy things with hardware?
 
  • #29
CRGreathouse said:
Oh sure, I agree completely -- but at that point in the thread it wasn't clear whether the original poster was asking for a client-side replacement (Java applet) or a server-side one (J2EE).

CRGreathouse, it was explained in page 1:

Ulysees said:
Tell that to a customer who wants to offer a geographical system like google maps. It could be done, for example:

- As many pictures that are shown when you click on links in HTML

- As a WIN32 application that downloads maps into memory and shows the bit you're looking at.

Is customer allowed to compare WIN32 with plain HTML or is it apples with oranges?

I've only worked with JAVA as a substitute for C++ in desktop applications.

The topic might as well be:

"AJAX versus stand-alone JAVA"
 
Last edited:
  • #30
Ulysees said:
I've only worked with JAVA as a substitute for C++ in desktop applications.

The topic might as well be:

"AJAX versus stand-alone JAVA"

Actually that wasn't clear to me until you posted that. Your essential question, then, is about what to use on the client side -- nothing (well, nothing but styled HTML I presume), or JavaScript + XML. In either case you're using server-side Java, right?

Or have I still misunderstood?
 
  • #31
Ulysees said:
The topic might as well be:

"AJAX versus stand-alone JAVA"

For the hundreth time, no. You can't compare AJAX to JAVA. It's like comparing a Honda Civic to a Cessna CJ1. You can NOT communicate with a server with just AJAX (Javascript + XML). What you want to compare is client JAVA with AJAX or web JSP/J2EE with AJAX.
 
Last edited:
  • #32
CRGreathouse said:
Actually that wasn't clear to me until you posted that. Your essential question, then, is about what to use on the client side -- nothing (well, nothing but styled HTML I presume), or JavaScript + XML. In either case you're using server-side Java, right?

Or have I still misunderstood?

That's it. Nothing (well, nothing but styled HTML I presume), or JavaScript + XML.

And yes, server-side java in either case. Thank you.
 
  • #33
Greg Bernhardt said:
For the hundreth time, no. You can't compare AJAX to JAVA. It's like comparing a Honda Civic to a Cessna CJ1. You can NOT communicate with a server with just AJAX (Javascript + XML). What you want to compare is client JAVA with AJAX or web JSP/J2EE with AJAX.

You don't understand how people think in business Greg. For them it's solution A, versus solution B, versus solution C (paperwork).
 
  • #34
Ulysees said:
That's it. Nothing (well, nothing but styled HTML I presume), or JavaScript + XML.

And yes, server-side java in either case. Thank you.

ah I see, that was really not clear to me either especially when you keep making your confusing A vs B comparisons.

If used correctly AJAX can be fantastic and it should be used, but if abused you can end up crippling your server. So i'd use an HTML page with some sprinkles of AJAX.
 
  • #35
I got stuck in another issue with java once. My applet was not allowed to access web pages (plain html) on servers other than the one I downloaded the applet from, "for security reasons" this was not allowed.

You know any workaround?
 
Last edited:
  • #36
Ulysees said:
I got stuck in another issue with java once. My applet was not allowed to access web pages (plain html) on servers other than the one I downloaded the applet from, "for security reasons" this was not allowed.

You know any workaround?

That's a security measure to prevent cross-site scripting - the alternative is to sign your JARs. A signed java applet will have full permissions.
 
  • #37
What about this one, -Job-:

> Is it possible to not ask the server at all, just get data straight from the cache? Because the main problem of the internet is delay, not download rate. It's a replacement for Outlook I'm trying to come up with, that interrogates the server every 5 minutes or whatever for any new messages (ie updates the cache every 5 minutes), and shows message threads immediately when requested.
 
  • #38
Ulysees said:
What about this one, -Job-:

> Is it possible to not ask the server at all, just get data straight from the cache? Because the main problem of the internet is delay, not download rate. It's a replacement for Outlook I'm trying to come up with, that interrogates the server every 5 minutes or whatever for any new messages (ie updates the cache every 5 minutes), and shows message threads immediately when requested.

You can load everything at once (e.g. load all message pages at once) and show only the active content but this is definitely not a good approach for many reasons.

The best strategy is to use AJAX (or frames) to preload content and hold it in the background until it needs to be used. For example in a mail client you can have the main page load with the first page of messages and subsequently perform AJAX requests to retrieve the next message pages so that when the user clicks to view messages 50 - 100 it can display them immediately with no load time (just some setup time). You just have to ensure that you manage the cache size and don't let it get out of control.
 
Last edited:
  • #39
But then I'd have to preload the entire forum in every session.

Can't I keep messages from previous sessions on the hard disk, just like Outlook does?

Because these days hard disk space is not an issue. Neither is bandwidth so much of an issue, unless every user downloads a ton of messages over and over in every session. The only remaining issue is delay.
 
Last edited:
  • #40
In fact I am sure there is a lot of future in this asynchronous approach, not just Asynchronous Javascript with Xml (ajax) but anything that achieves this objective, of interactivity in web pages.
 
Last edited:
  • #41
The browser can cache Ajax requests - if you ensure that the Ajax request is the same as previous ones then standard browser caching applies.
 
  • #42
-Job- said:
if you ensure that the Ajax request is the same as previous ones then standard browser caching applies.

You said this earlier:

> You can set content expiration headers on the server side to inform the browser to use cached content.

This means:

1. ask the server
2. server says "not expired yet"
3. show the cached content

We don't want this. We don't want to ask the server at all, the delay is too much. Instead, we want to show what's in the cache.

There's got to be a way to show what's in the cache from previous sessions.

Can the browser be forced to offline mode by a java applet?
 
Last edited:
  • #43
Ulysees said:
You said this earlier:

> You can set content expiration headers on the server side to inform the browser to use cached content.

This means:

1. ask the server
2. server says "not expired yet"
3. show the cached content

We don't want this. We don't want to ask the server at all, the delay is too much. Instead, we want to show what's in the cache.

There's got to be a way to show what's in the cache from previous sessions.

Can the browser be forced to offline mode by a java applet?

Really, too much delay? You have some pretty high standards. The browser makes HEAD requests which are very lightweight (contain no data) to check if new content is available - these are very fast - in addition you can also have the server set actual content expiration dates though I'm not 100% clear how the browsers handle these (they might ignore them to some degree).

IMHO I think you're getting too particular with the cache - you might be better off taking your app off the browser. You can use a single Java applet which makes socket requests to your site to retrieve content and stores it on the user's file system - so it's able to implement its own caching rules. However the main page containing the applet and the applet itself are cached (or not) according to the browser (still HEAD requests) - not to mention that the JAVA applet itself will be slower to load than any other approach. If delay is the problem then JAVA is not the solution.
 
Last edited:
  • #44
Actually I'm now reminded that Google is working on a new browser plugin called Google Gears, check it out - it's geared towards allowing applications to function offline so might be used to minimize content-related delays (it's still very much under development though). It implements a database accessible from Javascript, so you can store your content there.
 
Last edited:
  • #45
Thanks a million -Job-.

Certainly easier to convince people to install a plugin by google, than to run a windows executable of mine.

How they'd feel about giving lots of permissions to a JAVA applet is another story. Some hacker must have worked around this obstacle. But I wonder if there's a legitimate way to do it. Under the user's full supervision. Maybe the user could maintain a file and manually give it to the applet at the beginning of every session, and manually save it at the end of the session, if nothing better can be done.

Do you participate in any web-development-specific forums? Can you recommend a JAVA forum? Any AJAX one?
 
  • #46
Ulysees said:
Do you participate in any web-development-specific forums? Can you recommend a JAVA forum? Any AJAX one?

Not really - i don't have much time nowadays.
 
Back
Top