what is CGI(according to my knowledge CGI is process based) and (Servlets are Thread based) is it write please clear me and give me your comment.
bye
Amit Kumargupta
Ranch Hand
Joined: Apr 13, 2007
Posts: 54
posted
0
servlets are excuted as threads and servlets are language independent. servlet is used to handle request and response .Multiple concurrent request accessing the service method of the same servlet instance,for eg:when a client give a request one instance is created and receive a response from the server,the same client may give a request but it can access the same instance so,it can initialize only once and it cannot create a multiple instance for single client. so,if we avoid the multiple instance use servlets.
CGI are excuted as process and CGI are language dependent but for CGI each and every request it can create a new process , so every time it can receive a new request it can create a multiple instance for multiple clients,so it can take more memory address space. and so servlet is more advantage than CGI.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
0
I think Amit has it the wrong way around. Servlets are language-dependent - I'm not aware of any server implementation that uses the term "servlet" except Java.
CGI are a language-independent mechanism of how HTTP requests are bound to server processes. It is (or was) used with many languages, especially Perl.
Sorry for that. Yes I am wrong. I apologize for wrong phrase.
sunny dhoni
Greenhorn
Joined: Jul 24, 2007
Posts: 9
posted
0
Originally posted by Amit Kumargupta: [QB]servlets are excuted as threads and servlets are language independent. the same client may give a request but it can access the same instance so,it can initialize only once and it cannot create a multiple instance for single client. so,if we avoid the multiple instance use servlets.
In case of servlets, there is no concept of request coming from single client as far as handling those requests is concerned. every new request (from same client, unless cookies are enabled or from diff client) is considered separate. a new thread of execution is created for every request and has nothing to do with instances of the servlet. there is always a single instance of servlet irrespective of whether the request is coming from same client or a different client.
You have the right to remain silent. Anything you say will be misquoted, then used against you.