top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the difference between an Applet and a Servlet ?

+3 votes
553 views
What is the difference between an Applet and a Servlet ?
posted Jan 30, 2015 by Deepan

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+2 votes

Applets
- Applets are small applications designed to be transmitted over the network and executed by Java compatible web browsers.
- An Applet is a client side java program that runs within a Web browser on the client machine.
- An applet can use the user interface classes like AWT or Swing.
- Applet Life Cycle Methods: init(), stop(), paint(), start(), destroy()

Servlets
- Servlet is a server side component which runs on the web server.
- The servlet does not have a user interface.
- Servlet Methods: doGet(), doPost()

answer Feb 1, 2015 by Garima Gupta
+1 vote

APPLETS:

 1. It is a special type of java program which runs on any web browser.

 2. Applets resides at server but when client makes a request it completely loaded into a place in the browser.
   that place is known as SAND BOX. 

 3. Applet lives inside the sand box only. it does'nt have any access to any things which exists out side of the
    sand box.

 4. Applets can't communicate with any other server except where they resides.

 5. Applets are useful to develop the static web pages. 

SERVLETS:

 1.  Servlet is a purely server side program

 2.  Servlets always runs in the server.

 3.  Servlets can be placed in any web and application servers.

 4.  Servlets are useful to develop the dynamic web pages. 
answer Feb 2, 2015 by Karthick.c
Similar Questions
+2 votes
public class ServletClassName extends HttpServlet {
//declare instance variables for the servlet
int  instanceVar ; // not thread−safe
// overriding the Generic Servlet.init ( )
@Override
public void init ( ) throws ServletException {
// initialize instance variables, etc.
instanceVar = 0 ;
}
. . .
}

Per each page request, in the service() method (which eventually will be either doGet(), doPost(), or whatever),
you can manipulate instance variables.

Write a Servlet that counts the total number of visits (how many times it's being visited from all clients). The Servlet should display the following information

• Total Page Visits:
• Client Remote Address:
• Client Host Address: <client_fully_qualied_url__or__client_IP_address>

The last two can be obtained from the HttpServletRequest, Refer to the Java EE API

then how can re-do these using the Java API for HttpSession.

...