An Overview of JSP
1.1 Server-Side Scripting and Servlets
To better understand why JSP has risen so fast in the realm of Web application development, it is best to have a brief introduction to server-side scripting languages and Java servlets.
1.1.1 Server-Side Scripting Solutions
There are several common scripting solutions to create Web applications. These are scripts that are run on the server before the page is sent to the user.
Microsoft servers offer Active Server Pages (ASP). ASP is very similar to JSP. ASP allows developers to embed VBScript or JScript code directly into a Web page. ASP has to be compiled every time it is run, mirroring one of the major drawbacks of Common Gateway Interface (CGI) scripts. ASP is available to developers running Microsoft's Internet Information Server 3.0 or above.
By far, the biggest drawback of the major scripting solutions is their proprietary nature. All of the solutions discussed are dependent on either certain Web servers or specific vendors.
1.1.2 Java Servlets
Java servlets are a powerful alternative to CGI programs and scripting languages. Servlets are extremely similar to proprietary server APIs (application programming interfaces), but because they are written in the Java programming language, they can be easily ported to any environment that supports the Java Servlet API. Since they run in the Java Virtual Machine (JVM), they bypass the security problems that affect the server APIs.
Servlets are run inside a servlet engine. Each individual servlet is run as a thread inside a Web server process. This is a much more efficient solution than multiple server processes implemented by CGI programs. By running in threads, servlets are also very scaleable, and as they are a part of the Web server process themselves, they can interact closely with the Web server.
Servlets are extremely powerful replacements for CGI programs. They can be used to extend to any type of server imaginable. The built-in thread and security support make servlets a robust tool for extending a server service.
All major Web servers now support servlets. The major drawback of using Java servlets is in their power. The Java programming language is at once both powerful and complicated, and learning Java is a formidable task for the average Web developer.