File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Why servlet is better than Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Why servlet is better than Applet" Watch "Why servlet is better than Applet" New topic
Author

Why servlet is better than Applet

Glen Cai
Ranch Hand

Joined: Aug 24, 2002
Posts: 121
Applet can do much more than Servlet or JSP in GUI in browser.
But less and less people using Applet. Why?


"I, a universe of atoms, an atom in the universe." - Richard Feynman
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

They are different technologies.

While there is some general overlap, Applets are 'rich clients' and require java to be installed in the browser on the client and must run inside a secured applet container which restricts the abilities of the Applet. They also have some cross platform problems that effect their use. Also, the general trend is against rich clients, although my feel is that this is starting to turn.

Web applications are thin clients which (in general) only need the broswer to support HTTP and HTML. Quite a bit is being added to web applications, such as varieties of JavaScript (logic, validation, dynamic content and Ajax), plugins and such that are pushing more functionality into the browser.
Eddy Lee Sin Ti
Ranch Hand

Joined: Oct 06, 2005
Posts: 135
It's a client-side technology versus a server-side technology match. Applet extends the capability of the client browser while Servlet extends the capability of the web server.

Why use Servlet instead? Again, it's another match between thin client design and rich client design.

Depends on the design decisions, one might be more suitable than the other under certain circumstances.


SCJP, SCWCD, SCJWS, IBM 700,IBM 701, IBM 704, IBM 705, CA Clarity Technical<br /> <br /><a href="http://eddyleesinti.blogspot.com" target="_blank" rel="nofollow">http://eddyleesinti.blogspot.com</a>
Glen Cai
Ranch Hand

Joined: Aug 24, 2002
Posts: 121
Originally posted by David O'Meara:
They are different technologies.

While there is some general overlap, Applets are 'rich clients' and require java to be installed...


Do all the Browsers come with a JVM?
Masoud Kalali
Author
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

Originally posted by Glen Cai:


Do all the Browsers come with a JVM?



No not all of them , As far as i know just Opera shipped with a bundled JRE

you should download jre for other Browsers like IE , FF ,...
HTH


Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Masoud Kalali:
...As far as i know just Opera shipped with a bundled JRE...

Of course, Apples come with Java, so the Mac browser, Safari, is ready to go.

(I would also note that much of what applets did in the early days is now better handled by entirely different technologies, like Flash or script.)
[ October 15, 2005: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
There was a brief shining moment when Applets were first introduced that many predicted the end of HTML pages. Everyone would want rich user interfaces coded in Java! It just never worked out; applets were big enough they took too long to download, the browsers were not compatible enough and many other reasons. I was kind of disappointed ... coding rich apps in HTML and JavaScript and even the hip new AJAX architecture is not very satisfying to me.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

The question is a bit like asking which is better: a hammer or a screw-driver. Both are tools that perform somewhat related tasks, but neither is a substitute for the other.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jim Bao
Greenhorn

Joined: Aug 02, 2003
Posts: 8
Firewall is a big issue for Applet...
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Jim Bao:
Firewall is a big issue for Applet...


How so?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Jim Bao
Greenhorn

Joined: Aug 02, 2003
Posts: 8
Originally posted by Ben Souther:


How so?


I saw many Applets used RMI to talk to Server.
It would be OK if a special port opened for it in firewall.

Servlet uses HTTP on port 80. They are default open for all firewall.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

So the problem is with RMI, not with applets.
There are other ways for applets to communicate with the server.
Jim Bao
Greenhorn

Joined: Aug 02, 2003
Posts: 8
Originally posted by Ben Souther:
So the problem is with RMI, not with applets.
There are other ways for applets to communicate with the server.


Like what?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Object serialization over HTTP.
XML RPC

Both can operate nicely over port 80.
[ October 17, 2005: Message edited by: Ben Souther ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

I remember feeling bitterly disappointed when, after the initial excitement about this newfangled Java thing and applets that could be displayed on Web pages, I realized how poorly applets were integrated with HTML. They couldn't inspect the page they were embedded in. They couldn't interact with the forms they were next to. It was a great disappointment to me and seemed like an enormous oversight.

Then came Netscape 2.0 with Java support, and JavaScript and LiveConnect, but it was all too flaky and poorly documented and complicated. It was also a great disappointment.

What I wanted then -- and I suppose still would like now -- is a client-side language that was as well-integrated with the browser as JavaScript, but which had the capabilities of Java. If you could do everything JavaScript can do, and also create new form widget types with it, imagine the possibilities!


[Jess in Action][AskingGoodQuestions]
Jim Bao
Greenhorn

Joined: Aug 02, 2003
Posts: 8
Originally posted by Ben Souther:
Object serialization over HTTP.
XML RPC

Both can operate nicely over port 80.

[ October 17, 2005: Message edited by: Ben Souther ]


They are mostly implemented with Servlet.
Now you are asking Browser to support j2ee.
I think the JRE comes with Browser is J2SE.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

No, the browser doesn't need to implement j2ee for either of these.
There is a very small XML-RPC project on the apache site.
Object serialization over HTTP doesn't require anything but a JRE.

My point was that it's not accurate to claim that applets alone cause firewall problems.
[ October 17, 2005: Message edited by: Ben Souther ]
Jim Bao
Greenhorn

Joined: Aug 02, 2003
Posts: 8
Originally posted by Ben Souther:
No, the browser doesn't need to implement j2ee for either of these.
There is a very small XML-RPC project on the apache site.
Object serialization over HTTP doesn't require anything but a JRE.

My point was that it's not acurate to claim that applets alone cause firewall problems.


I guess the jar file of the "very small XML-RPC project of apache" is not
with most of the Browsers. Do you need to load it in the Browser for
each client?

Could you tell us how to do "HTTP-tunneling" in Java w/o using Servlet?
Do you need to build HTTP in your Java code?

It is not just port 80 but also HTTP protocol to make
the call going through the firewall. E.g., an IIOP call on port 80 will not go through.

If the Applets do not need to call servers (RMI, SocketServer, EJB, Corba...) or they are working inside firewalls, they should be OK.
It is normally very hard to let security people to open a port in firewall
for your application.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Jim Bao:

Could you tell us how to do "HTTP-tunneling" in Java w/o using Servlet?
Do you need to build HTTP in your Java code?


To do object serialization, you would need Java on the server.
I didn't mean to imply otherwise.

You can do HTTP-Tunneling with any server side technology though.
The first time I've seen it done was with Perl on the server.
In that example, the servlet was posting form encoded strings with the
UrlConnection object, and receiving delimited strings in return.
In short, to answer your question, yes, you would do this with HTTP.

As for xml-rpc, you would need to include the libraries with your applet.
Here is the url if you're interested:
http://ws.apache.org/xmlrpc/

I agree, it is hard to get people to open firewall ports.
Glen Cai
Ranch Hand

Joined: Aug 24, 2002
Posts: 121
What I'm looking for is 3D GUI (similar to Java3D) in browser.
I think HTML or Servlet can not do it. Is it possible to use
Applet with Java3D?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Glen Cai:
What I'm looking for is 3D GUI (similar to Java3D) in browser.
I think HTML or Servlet can not do it. Is it possible to use
Applet with Java3D?


Glen,
You might want to start a new thread for this question.
Long threads like this often get ignored by people who've already read the first 4 or 5 posts and then lost interest.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why servlet is better than Applet