The document provides an overview of server-side scripting technologies including CGI, Java servlets, and JSP. CGI scripts are executed on the web server with disadvantages of high server load. Servlets are Java programs that provide platform independence, performance, extensibility, and safety. JSPs simplify server-side scripting by allowing Java code to be embedded within HTML pages and are translated to servlets. The life cycle of a servlet including initialization, processing requests, and destruction is also summarized.
3. CGI (common gateway interface)
1. Scripts are linked and executed on the web
server.
2. CGI includes Perl, C++, Visual Basic and even
java.
3. biggest disadvantage to using CGI was that it
placed a tremendous load on your Web
server as it is executed on the web server
5. Types of servlet
• Generic Servlet Class (Inherit)
• HttpServlet Class(Inherit)
• Servlet interface (Implement)
6. HttpServlet Web
Request components
Web
Client
JavaBeans
HttpServlet
Components
Response
7. Life cycle of Servlet
Import java.io.*;
Import javax.servlet.*;
Import javax.servlet.http.*;
Public class TestServlet extends HttpServlet
{
public void init() // called only once at start
{
8. /* It can be used for those elements which always
need an initialization like JDBC but it is optional to
use */
}
Public void
service/doGet/doPost(HttpServletRequest
request,HttpServletResponse response)
throws ServletException , IOException
{
/* Common method used for initializing JDBC
,server based operations and redirect to pages.
*/
10. JSP(Java Server Page)
• Addressing jsp page is simpler than servlets.
• Servlet goes with two pages hand in hand
like for logging
login.html (used as an index)
login.java (used for request and response).
• Only one page enough login.jsp . JSP provides
better compatibility with web development
tools.
12. What is JSP ?
Template for a web page that uses java code
to generate HTML documents dynamically.
JSP runs in a server side component known
as JSP container.
JSP Container translates them into equivalent
java code.
JSP is similar to ASP and PHP, but it uses
the Java programming language.
18. MVC Model
Database
Model Access
Presentation DB
Data Model Updates
User Input
View Next View Controller
Delegate State
actions
Actions
Notas do Editor
Platform IndependenceServlets are written entirely in java so these are platform independent. Servlets can run on any Servlet enabled web server. For example if you develop an web application in windows machine running Java web server, you can easily run the same on apache web server (if Apache Serve is installed) without modification or compilation of code. Platform independency of servlets provide a great advantages over alternatives of servlets.PerformanceDue to interpreted nature of java, programs written in java are slow. But the java servlets runs very fast. These are due to the way servlets run on web server. For any program initialization takes significant amount of time. But in case of servlets initialization takes place first time it receives a request and remains in memory till times out or server shut downs. After servlet is loaded, to handle a new request it simply creates a new thread and runs service method of servlet. In comparison to traditional CGI scripts which creates a new process to serve the request. ExtensibilityJava Servlets are developed in java which is robust, well-designed and object oriented language which can be extended or polymorphed into new objects. So the java servlets take all these advantages and can be extended from existing class to provide the ideal solutions.SafetyJava provides very good safety features like memory management, exception handling etc. Servlets inherits all these features and emerged as a very powerful web server extension.SecureServlets are server side components, so it inherits the security provided by the web server. Servlets are also benefited with Java Security Manager.