RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Tuesday, May 11, 2010

CGI and Advantages Of Java Servlets Over Perl


There are two things a Web Server Application alone can't do:
1) Generate Dynamic Content (generating dynamic / on-the-fly web pages)
2) Perform Operations with form Data.
To perform these operations, the web server application uses helper applications.
These helper Applications perform the operations and sends information back to the web server application. (The web server application thinks that the page received is just another static page.)

The non-Java term for the helper application is CGI(Common Gateway Interface).

Most CGI programs were written using Perl and now I would like to bring out the advantages of Java over Perl.
* Java is Performance effective. With Perl, the server has to launch a heavy weight process for each and every request for that resource.
* Now we might get a thought that similarly in Java, each instance of the JVM would be a heavy weight process.
* In our case, Servlets stay loaded only once. Client requests for a servlet resource are handled as seperate Threads of the single running Servlet. We don't have the overhead of starting the JVM and loading the class.
* It can be pointed out that Web servers are able to keep a single Perl program running between clients, but, the point is not all web servers can do that. It's a special case which doesn't apply to all Perl CGI programs.
* Furthermore, Servlets can be a J2EE Client, whereas a Perl CGI Program cannot!

More to be discussed with respect to J2EE Clients.

What's a MIME type

The Content-Type response header's value in the HTTP Response is known as MIME type.
The MIME type tells the browser what kind of data the browser is about to receive so that the browser will know how to render that. The MIME type is any of the types sent in the HTTP Request's "Accept:" Header.


In the HTTP POST Request, if we have

Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/

Content-Type: text/html
is the possible MIME type sent using the HTTP Response.