• No results found

Server-Side Web Development JSP. Today. Web Servers. Static HTML Directives. Actions Comments Tag Libraries Implicit Objects. Apache.

N/A
N/A
Protected

Academic year: 2021

Share "Server-Side Web Development JSP. Today. Web Servers. Static HTML Directives. Actions Comments Tag Libraries Implicit Objects. Apache."

Copied!
7
0
0
Show more ( Page)

Full text

(1)

Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Server-Side Web Development

JSP Lecture #4 2007 Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time 1 Web Servers Request Processing 2 JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects 3 Apache Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Web Servers

• Serves resources via HTTP

• Can be anything that serves data via HTTP

• Usually a dedicated machine running web server software

• Can contain modules that processes requests

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Request Processing

1 A Connection is established 2 A HTTP request is received

3 The (logical) path in the request is translated

4 The requested resource is identified (via the path)

5 A server module handling that resource is invoked

6 The module processes the request and generates a reply

7 A mime-type is provided and a HTTP response is created

8 The HTTP response is sent (possibly in increments)

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

JSP Processing

1 A JSP page is requested

2 Server checks if a Java Servlet for the page exists

3 If no Servlet is found (or newer JSP is detected),

the JSP is translated to Java (a Servlet class is created)

4 The Java Servlet is compiled

5 The Java Servlet is invoked and processes the request

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

JavaServer Pages (JSP)

• HTML with extra XML-tags

• (Scripted server-side) Java for the web

• A way to provide dynamic content in web pages

• XML-tags act as front-ends for Java classes

• May include other pages dynamically

• JSPs are compiled into Java Servlets

• JSP code is never visible to clients

• Generates response (HTML) dynamically

(2)

Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

JSP Syntax

JSP may contain • Static HTML • Directives • Scripting Elements • Actions • Comments • Tag Libraries • Implicit Objects Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

JSP Script Tags

• Directives <%@ ... %> • Declarations <%! ... %> • Scriptlets <% ... %> • Expressions <%= ... %> • Comments <%-- ... --%> Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Static HTML

• All HTML is treated by JSP as static text

• HTML may be mixed with JSP in any way

• All non-JSP tags are treated as HTML

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Directives

<%@ ... %> Types of JSP directives • Page • Include

• Tag Libraries (aka Custom Tags)

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Page Directives

<%@ page attribute="..." %>

• Instructs the JSP engine how to process the JSP

• Attributes determine directive content

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Page Directive Attributes

• language - selects scripting language (Java)

• extends - base class for generated Servlet

• import - Java class / package import

• session - enable session tracking (default: true)

• buffer - set output buffer size

• autoFlush - enable auto flushing of output buffer

• isThreadSafe - thread safe marker

• info - page information (author, version, copyright etc)

• errorPage - set default error page

• isErrorPage - enable exception tracking on page

(3)

Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Include Directive

<%@ include file="page.jsp" %>

• Includes another page at translation time

• Included page becomes part of Servlet

• Generates error if page not found

Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Tag Libraries

<%@ taglib uri="taglib.tld" prefix="prefix" %>

• Loads a tag library

• Tags are usable via the specified tag prefix

• The JSP version of language extension

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Directive Examples

<%@ page import="examples.*, examples.tags.*" %> <%@ taglib uri="/WEB-INF/examples-taglib.tld" prefix="examples" %> <%@ include file="/includes/head.jsp" %> ... <examples:ValidateParameters parameters="name,age"/> ... <%@ include file="/includes/foot.jsp" %> Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Scripting Elements

• Declarations <%! ... %> • Scriptlets <% ... %> • Expressions <%= ... %> Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Declarations

• Content placed in Servlet body (members)

• Used to declare members and methods

• Does not produce HTML output

• Declared content is later used by Scriptlets or expressions

• Lines must be terminated with a semicolon

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Declaration examples

<%!

public int getSum (int x, int y) {

return x + y; }

%>

<jsp:declaration>

public int getSum (int x, int y) {

return x + y; }

(4)

Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Scriplets

• Content placed in Servlet jspService() method (local variables and in-line code)

• Used to embed Java code directly in the page

• May produce HTML output (via out.println())

• Lines must be terminated with a semicolon

Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Scriptlet examples

<% int x = 1; int y = 2; int sum = x + y; %> <jsp:scriptlet> int x = 1; int y = 2; int sum = x + y; </jsp:scriptlet> Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Expressions

• Content output directly to HTML

• Used as an alias for out.println()

• Code must evaluate to an expression

• Lines must not be terminated with a semicolon

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Expression examples

1 + 2 = <%= 1 + 2 %> 1 + 2 = <jsp:expression> 1 + 2 </jsp:expression> Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Actions

• include - include another page

• forward - forward request to another resource

• param - specify parameters when calling or forwarding

• plug-in - generates browser-specific code for applets

• fallback - content if browser does not support applets

• getProperty - get a property from a JavaBean

• setProperty - set a property on a JavaBean

• useBean - use a JavaBean

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Include Action

<jsp:include page="page.jsp"/>

• Includes another page at request time

• Generates a request to included page Servlet

• Ignored if page not found

• Usually used to call declared methods

(5)

Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Forward Action

<jsp:forward page="page.jsp"/>

• Forwards request to another resource

• Control is not returned

Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Param Action

<jsp:forward page="page.jsp">

<jsp:param name="name" value="value"/> </jsp:forward>

• Used to specify parameters when including / forwarding

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

HTML Comments

<!-- HTML comment -->

• Evaluated by server (as HTML)

• Part of the server response / web page

• Visible in page source from web browser

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

JSP Comments

<%-- JSP comment --%>

• Not evaluated by server

• Not part of the server response / web page

• Not visible in page source from web browser

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Tag Libraries

• Java classes

• Implements the JSP Tag Extension API interfaces

• Usable as JSP tags in JSPs

• Java class coupled to a tag using a XML-descriptor

• Tags can control JSP processing

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Implicit Objects

• request - HTTP request • response - HTTP response

• out - response stream

• session - web application session

• pageContext - page context data

• application - Servlet context data

• config - Servlet configuration data

• page - Servlet object

(6)

Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Apache

• Apache Software Foundation

• Non-profit organization developing open-source software

• http://www.apache.org/ Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Apache HTTP Server

• A (patchy) web server

• Arrived early and helped shape the web

• Runs 58% of the worlds web sites (March 2007)

• Serves HTTP and HTTPS requests

• Runs CGI-scripts for dynamic content

• Can host modules for PHP, JSP, ASP etc

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Apache Tomcat

• Servlet & JSP container with built-in web server

• Can run standalone or as a module in Apache

• Serves HTTP and HTTPS requests

• Requests may have been forwarded from HTTPD Server

• Contains configuration and management tools

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Apache Axis2

• Web Service framework

• Refactorization of Axis

• Contains tools for generating language bindings and interfaces

• Includes a Web Service hosting environment

• Can run as a module / web application in Tomcat

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Apache Ant

• A build tool for software development

• ”Make for Java”

• Used to automate build, deployment and clean-up

Server-Side Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Apache Derby

• A Pure-Java relational database management system

• Can be embedded into Java programs

• No configuration required

• No management clients provided

(7)

Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Other Related Apache Project

• Struts - web application framework

• Jakarta - server-side Java projects

• Xalan - XSLT processor

• Xerces - A validating XML parser

• ... Web Development JSP Today Web Servers Request Processing JavaServer Pages (JSP) Static HTML Directives Scripting Elements Actions Comments Tag Libraries Implicit Objects Apache Next Time

Next Time

• Using JSP/Servlets

References

Related documents

However, it is important to tell your doctor or nurse specialist about any other medicines you are taking, including herbal, complementary or alternative therapies, as these may

We show that regression-adjusted inter-industry wage di¤erentials (i.e., the estimated coe¢ cients on indicator variables for industry) that do not control for unobserved person,

• Delay (usurpation, deception) - Availability • Denial of service - Availability Web Development using Java, JSP, and Web Services Web Security Today Security Threats Attacks

Web Development using Java, JSP, and Web Services Web Technologies Today Web Technologies Internet WWW Protocols TCP/IP HTTP Apache Next Time HTTP POST Request. • Used to submit

Kalandoor Career DMCC Careers Dubai Customs DP World Career Dalkia Dubai Career ADGAS Career Mattex Career HR@mattex.com. Paris Gallery

Gainesville State College came to the Athens area in 2003 and draws students from around the state.. The university enrolls 8,883 students and employs 551 full-time

The SW algorithm computes the optimal local alignment between two sequences following a dynamic programming approach and can be divided in two stages: (1) similarity matrix (also

Nearly 19 percent of the licensed drivers in South Dakota were under 25, but 39.2 percent of the drinking drivers in fatal and injury accidents and 48.4 percent of the speeding

Kako diplomski rad obuhva ć a analize novinskih komentara u listovima Me đ imurske novine i List Me đ imurje kojim se urednici obra ć aju javnosti, ali i pisma č itatelja

Because this form of knowledge plays a leading role in fostering personal changes, and because Nhat Hanh holds that some personal changes have systemic implications, examining

The Statement of Owner Equity allows you to determine to what degree the change in equity was caused by (1) earnings from the business, and nonfarm income, in excess

Minimum regulated expression of ovo-B requires a short region flanking the transcrip- tion start site, suggesting that the ovo-B core promoter bears regulatory information in

prospective cohort study involving 723 physician practices in ten countries, has reported that the risk of incident ankle and upper leg fractures was significantly higher in

Unformed stool or diarrhea material is an indication that a person with an infectious disease of the digestive tract has used the pool. Some of these infectious diseases

When a client requests a document written in a server-side scripting language from the web server, the server will execute the script and generate a static HTML document that is

Instantiate and initialize data abstraction components Execute JSP page JSP Page Clients Data Sources Web Layer Bean Custom Tag WML HTML XML JSP Page JSP Page XML WML XSLT a L

JSP file and executes the servlet) (HTTP get or post) (HTML File) Response Request Servlet File Response Request Java Component JSP Engine... User request a JSP Execute Servlet

Java Web Technologies, Servlets, JavaServer Pages, JavaServer Faces, Web Technologies in Netbeans, Creating and Running a Web Application in Netbean, Examining a JSP File, Examining

Application servers Enterprise JavaBean (J2EE) JavaBean (J2SE) .NET Web servers and scripting ASP Perl Java servlet PHP Windows Server Apache JSP Today’s Environment Web

– Data contained in app server’s request, session, application scopes App Server Server-side Code (Java servlets, JSP) Browser http request html response?.

Servlets Summary Servlet-Centric Architecture Client(s) Web Browser Http Post/Get Web Tier Servlets execute business logic, provide data access, and Create HTML pages

buyers: the case of klang valley, malaysia. Tan,

The exact estimation of quantization effects requires numerical simulation and is not amenable to exact analytical methods.. But an approach that has proven useful is to treat