Tuesday, March 13, 2007

Programming web servers: Languages for the web

Servlet

Techtarget (2005, servlet, para.1) defines that a servlet is a little size of program which runs on a server. This term was found in the context of the Java applet, a small program which is sent along with a Web (HTML) page but in a separate file. Java applets always running on a client and can provide a calculation for a user or placing an image on user interaction.

Some programs access databases based on user input should be on the server. Indeed, these have been solved using a Common Gateway Interface (CGI) application. On the other hand, If a Java running in the server, these programs can run with the Java programming language. The advantage of a Java servlet on servers with a great number of traffic is that they can be executed faster than CGI applications. The amount of system increasing for each request is slight. It means that rather than a separate program process to be created, every user request is turned as a thread in a single daemon process.

Wikipedia (2007, Java Servlet, p.1) determines several steps of the servlet life cycle:
  1. The servlet class runs in the container during start-up.
  2. The container invokes the init() method. This method begins with the servlet and has to be called before the servlet can allow any requests. In the whole life of a servlet, the init method needs to be called at once.
  3. After initialization process, the servlet can provide client-requests. A request is provided in their own separate thread. The container will call the service() method of the servlet for each request. The service() method establishes HTTP request (GET, POST, etc) and accordingly call the such methods doGet(), doPost(), doTrace(), etc. The developer of the servlet has to provide implementation for these methods. If an implementation for doPost() not available yet, it means that the servlet cannot manage POST requests. A developer must never the service() method.
  4. At the end, the container calls the destroy() method that stops the servlet service. The destroy() method such as init() is called only once in the life-cycle of a servlet.

JSP

JSP (2007, JSP, para.1) highlights that Java Server Page or JSP is a server-side technology developed by SUN and can be an extension for the Java servlet technology. JSPs have dynamic coding ability that runs in tandem with HTML code, dividing the page logic from the static elements which is the actual display and design of the page to make the HTML more functional (for example, dynamic database queries).

A JSP needs to be translated into Java servlet before being run and it loads HTTP requests and resulting responses such any servlet. In fact, JSP technology is an easiest way to code a servlet. A translation does in the first time when the application is run. A JSP translator is a trigger for the .jsp file name extension in a URL. JSPs are fully compatible with servlets. User can obtain an output from a servlet or resend the output to a servlet and a servlet can include ouput from a JSP or resend output to a JSP.

Wikipedia (2007, JavaServer Pages, para.5) divides a JSP into several pieces:

  1. Static data (HTML)
  2. JSP directives (include directive)
  3. JSP scripting variables and elements
  4. JSP actions
  5. custom tags

Perl

According to Lenzer (2004, Perl, para.1) Perl is a text programming language as same as syntax to the C language and includes some UNIX facilities such as awk, tr and SED. Perl is an interpreted language which can be compiled before execution into either cross-platform bytecode or C script. When it compiled, a Perl program will have the same speed as fully precompiled C language program. Perl is a best way to develop common gateway interface (CGI) programs because it has better text manipulation facilities.

Generally, Perl is much easier to learn and code than C and C++ languages. Perl programs can be sophisticated as well. A plug-in can be added for some servers (for example Apache), so Perl will run permanently in memory and causing short time to compile and faster execution of CGI Perl scripts.


About Perl (2007, Perl features, para.3) describes Perl’s features as follow:

  1. Perl is taken from the best features of other scripting languages, such awk, sh, C, etc.
  2. Perl database integration interface (DBI) works with third-party databases, such as Sybase, Postgres, Oracle, MySQL, etc.
  3. Perl also works with XML, HTML, etc.
  4. Perl supports object-oriented and procedural programming.
  5. Perl interfaces with external C++/C libraries over SWIG or XS.
  6. Perl can be more widely use because there are more than 500 third party modules available in the Comprehensive Perl Archive Network (CPAN).
  7. Perl can be implemented into other systems.

About Perl (2007, Perl and the Web, para.4) describes Perl and its relation to the Web:

  1. Perl is the most popular among any other web programming language because of its ability for text manipulation and rapid development cycle.
  2. Perl is also known as “the duct-tape of the Internet”.
  3. Perl can be used to manage encrypted Web data such as e-commerce transaction.
  4. Part of Perl’s standard distribution such as Perl’s CGI.pm module, makes it easy to handle HTML forms.
  5. Perl can be extended into web servers to increase processing by 2000%.
  6. mod perl used by the Apache web server to extend a Perl interpreter.
  7. Perl’s DBI package is a package to make web-database integration easier.

References

About Perl 2007, last edited n.a., Perl.org, viewed 3 March 2007, <http://www.perl.org/about.html>

Bergsten, H 1999, An Introduction to Java Servlets, last updated 10 March 1999, Jupitermedia Corporation, Darien, CT, USA, viewed 3 March 2007, <http://www.webdevelopersjournal.com/articles/intro_to_servlets.html>

Hall, M 1999, Servlets and JavaServer Pages (JSP), last updated n.a., coreservlets.com Inc., Reisterstown, MD, USA, viewed 3 March 2007,

JSP 2007, last edited n.a., Jupitermedia Corporation, Darien, CT, USA, viewed 3 March 2007, <http://www.webopedia.com/TERM/J/JSP.html>

Lenzer, J 2004, Perl, last updated 17 June 2004, SearchWebServices.com, Needham, MA, USA, viewed 3 March 2007, <http://searchopensource.techtarget.com/sDefinition/0,290660,sid39_gci214291,00.html>

Perl 2007, last edited n.a., Jupitermedia Corporation, Darien, CT, USA, viewed 3 March 2007, <http://www.webopedia.com/TERM/P/Perl.html>

Servlet 2007, last edited n.a., Jupitermedia Corporation, Darien, CT, USA, viewed 3 March 2007, <http://www.webopedia.com/TERM/S/servlet.html>

Techtarget 2003, Java Server Page, last updated 14 April 2003, SearchWebServices.com, Needham, MA, USA, viewed 3 March 2007, <http://searchwebservices.techtarget.com/sDefinition/0,290660,sid26_gci214048,00.html>

Techtarget 2005, servlet, last updated 4 April 2005, SearchWebServices.com, Needham, MA, USA, viewed 3 March 2007, <http://searchwebservices.techtarget.com/sDefinition/0,290660,sid26_gci212966,00.html>

Wikipedia 2007, Java Servlet, last updated 6 January 2007, Wikipedia Foundation, Inc., n.a., viewed 3 March 2007, <http://en.wikipedia.org/wiki/Java_Servlet>

Wikipedia 2007, JavaServer Pages, last updated 27 January 2007, Wikipedia Foundation, Inc., n.a., viewed 3 March 2007, <http://en.wikipedia.org/wiki/JavaServer_Pages>

Wikipedia 2007, Perl, last updated 21 January 2007, Wikipedia Foundation, Inc., n.a., viewed 3 March 2007, <http://en.wikipedia.org/wiki/Perl>

No comments: