Introduction servlets and jsp
This presentation is the property of its rightful owner.
Sponsored Links
1 / 12

Introduction Servlets and JSP PowerPoint PPT Presentation


  • 44 Views
  • Uploaded on
  • Presentation posted in: General

Introduction Servlets and JSP. Celsina Bignoli [email protected] Dynamic web pages. Content may change based on identity of the user user’s browser type information provided by the user selections made by the user. CGI. CGI (Common Gateway Inteface)

Download Presentation

Introduction Servlets and JSP

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Introduction servlets and jsp

Introduction Servlets and JSP

Celsina Bignoli

[email protected]


Dynamic web pages

Dynamic web pages

  • Content may change based on

    • identity of the user

    • user’s browser type

    • information provided by the user

    • selections made by the user


Introduction servlets and jsp

CGI

  • CGI (Common Gateway Inteface)

    • outlines how a web server communicates with a program.

    • Typically written in Pearl (or C)

  • CGI scripting is not efficient

    • for every request the web server has to create a new process load an interpreter run the program and dispose of the process once done.


Cgi improvements

CGI improvements

  • Fast-CGI

    • runs program in a external process or pool of processes

  • mod_perl, NSAPI, ISAPI

    • run server-side programs in the same process as the web server

    • available only on some web servers


Servlets

Servlets

  • Server side Java programs

  • Solve scalability issue

    • serlvets are run on threads of execution not separate processes

  • Solve portability issue

    • runs on every platform that supports Java

    • supported by all most popular web servers

  • Issue

    • html tags are embedded in java programs within out.print() statements


Introduction servlets and jsp

JSP

  • server-side technology

  • separate dynamic content from static content of a page

    • Java scriptlets embedded into html-like page

  • Separate the work of

    • java programmers

    • page authors


Jsp relationship to servlets

JSP relationship to Servlets

A JSP is converted into a Servlet


Servlet example

Servlet Example

import java.text.*;

import java.util.*;

import

public class DateServlet extends HttpServlet{

public void doGet(HTTPServletRequest request,

HttpServletResponse response)

throws ServletException, IOException

{

response.setContentType(“text/html’);

PrintWriter out = response.getWriter();

out.println(“<html>”);

out.println(“<head><title><Date Example</title></head>”);

out.println(“<body>”);

out.println(“Today is: “);

Date d = new Date();

out.println(“<em>” + DateFormat.getInstance().format(d)+ “</em>”);

out.println(“<body>”);

out.println(“</html>”);

}

}

embedded HTML


Jsp example

<%

Date d=new Date();

String today = DateFormat.getInstance().format(d);

%>

JSP Example

JSP tag

<%@ page import=“java.text.*’, java.util.*”%>

<html>

HTML

<head><title><Date Example</title></head>

<body>

Scriptlet

Today is:

<em><%=today%></em>

</body>

</html>

Example.jsp

  • Static: HTML/XML elements

  • Dynamic: scriptlets

  • Additional: special JSP elements


Jsp alternatives

JSP alternatives

  • Active Server Pages

    • allows you to add VBScript or JScript code to the page

    • primarily a solution for te Windows platform

  • PHP

    • open source web-scripting language.

    • extensive set of predifined functions to access databases, LDAP directories, mail servers etc…

    • widely supported

  • ColdFusion

    • ColdFusion Markup Language(CFML) accessing databases, files, mail servers etc…

    • custom elements can be developed in C++ or Java


Jsp unique features

JSP Unique Features

  • JSP is a specification, not a product

    • competing implementations

  • integral part of J2EE

    • access all features of the Java language


How to get started

How to get Started

  • Install JDK 5.0

  • Download Apache Tomcat 5.5 from:

    www.apache.org

  • Use a regular editor or an IDE that supports JSP development

    • Eclipse

    • JBuilder

    • JCreator

    • Oracle JDeveloper

    • NetBeans

    • Macromedia DreamWeaver


  • Login