Solved

servlet advantages

Posted on 2014-03-26
6
320 Views
Last Modified: 2014-04-17
Hi,

I was reading servlet advantages as below(http://www.javatpoint.com/servlet-tutorial)


   1. better performance: because it creates a thread for each request not process.
  2.  Portability: because it uses java language.
   3. Robust: Servlets are managed by JVM so no need to worry about momory leak, garbage collection etc.
  4.  Secure: because it uses java language..


I have not understood point number1,3. Can you please explain.

please advise
Any links resources ideas highly appreciated. Thanks in advance
0
Comment
Question by:gudii9
  • 2
  • 2
  • 2
6 Comments
 
LVL 26

Expert Comment

by:dpearson
ID: 39958178
The comments on that page are based on comparing using a Java servlet to using a really old technology - cgi scripts.

Those worked by running a small executable program on the server to process a request from a user.

So from that:
#1 follows because to servlet is a thread that executes inside an already running process (the Java web application, like Tomcat), rather than having to start a completely new process (the executable cgi program) from scratch.

#3 follows because a servlet is part of a Java program, so it runs (like all Java programs) inside the JVM which means it comes with garbage collection and the other benefits of being a program in a managed environment, rather than a C++ executable (like a CGI script).

Does that make sense?

Doug
0
 
LVL 12

Expert Comment

by:Gibu George
ID: 39958286
JVM takes care of clearing the unreferenced objects from the memory, which is called automatic garbage collection. Some details are available here :
http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html
0
 
LVL 7

Author Comment

by:gudii9
ID: 39973376
Those worked by running a small executable program on the server to process a request from a user.
'

How running cgi script is different from servlet. pelase advise
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 12

Accepted Solution

by:
Gibu George earned 250 total points
ID: 39973945
IServlets are run in one process (HTTP server with additional features, which called Servlet Container) and they exist as long as that process exists.

CGI means every time there's client request, HTTP server creates new instance of process to serve this request. This is performance killer. Additionally, since there's new process per each request, it means CGI can't aggregate data from several requests in memory, as Servlets can, and must resort to external persistent storage (file or DB). This is performance killer as well.
0
 
LVL 7

Author Comment

by:gudii9
ID: 39976489
it means CGI can't aggregate data from several requests in memory, as Servlets can,

How servlets do this task currently? please advise
0
 
LVL 26

Assisted Solution

by:dpearson
dpearson earned 250 total points
ID: 39976931
When a servlet runs it's just a part of a long running Java process - the web server.  E.g. Tomcat.

Tomcat doesn't start and stop with each request.  It's always in memory and can store information from a series of requests.

A cgi process on the other hand starts from scratch each tine in response to a request and exits completely when the request finishes. So there's no long running process in memory that you can use to store long term data.

Doug
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hasOne  challenge 59 126
powerN  challenge 3 57
countHi2 challenge 7 52
eclipse shortcuts 9 45
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now