introduction to jsp liu haibin 2014-10-03

18
Introduction to JSP Introduction to JSP Liu Haibin Liu Haibin 22-08-29 22-08-29

Upload: pekelo

Post on 08-Jan-2016

21 views

Category:

Documents


1 download

DESCRIPTION

Introduction to JSP Liu Haibin 2014-10-03. Overview. Introduction A JSP case JSP vs ASP. What is JSP technology?. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Introduction to JSP Liu Haibin 2014-10-03

Introduction to JSPIntroduction to JSP

Liu HaibinLiu Haibin

23-04-2123-04-21

Page 2: Introduction to JSP Liu Haibin 2014-10-03

OverviewOverview

IntroductionIntroduction

A JSP caseA JSP case

JSP vs ASPJSP vs ASP

Page 3: Introduction to JSP Liu Haibin 2014-10-03

What is JSP technology?What is JSP technology?

JavaServer Pages (JSP) technology provides a JavaServer Pages (JSP) technology provides a simplified, fast way to create web pages that display simplified, fast way to create web pages that display dynamically-generated content. The JSP dynamically-generated content. The JSP specification, developed through an industry-wide specification, developed through an industry-wide initiative led by Sun Microsystems in June, 1999, initiative led by Sun Microsystems in June, 1999, defines the interaction between the server and the defines the interaction between the server and the JSP page, and describes the format and syntax of JSP page, and describes the format and syntax of the page. Sun has made the JSP specification freely the page. Sun has made the JSP specification freely available to the development community, with the available to the development community, with the goal that every Web server and application server goal that every Web server and application server will support the JSP interface. JSP pages share the will support the JSP interface. JSP pages share the "Write Once, Run Anywhere" characteristics of Java "Write Once, Run Anywhere" characteristics of Java technology. JSP technology is a key component in technology. JSP technology is a key component in the Java 2 Platform, Enterprise Edition, Sun's highly the Java 2 Platform, Enterprise Edition, Sun's highly scalable architecture for enterprise applications.scalable architecture for enterprise applications.

Page 4: Introduction to JSP Liu Haibin 2014-10-03

What is a JSP page?What is a JSP page?

A JSP page is a page created by the web A JSP page is a page created by the web developer that includes JSP technology-developer that includes JSP technology-specific and custom tags, in combination specific and custom tags, in combination with other static (HTML or XML) tags. A with other static (HTML or XML) tags. A JSP page has the extension .jsp or .jspx; this JSP page has the extension .jsp or .jspx; this signals to the web server that the JSP signals to the web server that the JSP engine will process elements on this page. engine will process elements on this page. Using the web.xml deployment descriptor, Using the web.xml deployment descriptor, additional extensions can be associated additional extensions can be associated with the JSP engine. with the JSP engine.

Page 5: Introduction to JSP Liu Haibin 2014-10-03

A simple JSP pageA simple JSP page

<%@ page language=“java”%><%@ page language=“java”%><%@ page contentType="text/html; charset=ISO-8859-1"%><%@ page contentType="text/html; charset=ISO-8859-1"%><html><html><head><head><title>A simple case</title><title>A simple case</title></head></head><body bgcolor="#FFFFFF" text="#000000"><body bgcolor="#FFFFFF" text="#000000"><% String temp="the time now is:";%><% String temp="the time now is:";%><%=temp%><%=temp%><%=(new java.util.Date()).toString()%> <%=(new java.util.Date()).toString()%> </body></body></html></html>

Page 6: Introduction to JSP Liu Haibin 2014-10-03

Output screenOutput screen

Page 7: Introduction to JSP Liu Haibin 2014-10-03

JSP’s implementationJSP’s implementation

*.classrequest

response

jsp parserJDK

*.jsp *.java

implementation

Page 8: Introduction to JSP Liu Haibin 2014-10-03

OverviewOverview

IntroductionIntroduction

A JSP caseA JSP case

JSP vs ASPJSP vs ASP

Page 9: Introduction to JSP Liu Haibin 2014-10-03

Flow chartFlow chart

Login

Is new user?Yes

No

New user

Enter username& password

Username &password

Chooseidentity

Commonuser

Vip user

Creditnumber

Check

Submit

Submit

Fail

Success

Choose identity

Check

Submit

Logout

Success

Welcome

Fail

Page 10: Introduction to JSP Liu Haibin 2014-10-03

OverviewOverview

IntroductionIntroduction

A JSP caseA JSP case

JSP vs ASPJSP vs ASP

Page 11: Introduction to JSP Liu Haibin 2014-10-03

JSP vs ASPJSP vs ASP

JSP and ASP have some basic concepts in JSP and ASP have some basic concepts in common. common.

1) They both make use of simple sever-1) They both make use of simple sever-side scripting to provide access to Web side scripting to provide access to Web server information and functionality. server information and functionality.

2) They both have similar styles of 2) They both have similar styles of delimiting this scripting from a page's delimiting this scripting from a page's content. content.

Page 12: Introduction to JSP Liu Haibin 2014-10-03

Because it uses ActiveX controls for its Because it uses ActiveX controls for its components, ASP technology is basically components, ASP technology is basically restricted to Microsoft Windows-based restricted to Microsoft Windows-based platforms. Offered primarily as a feature of platforms. Offered primarily as a feature of Microsoft IIS, ASP technology does not work Microsoft IIS, ASP technology does not work easily on a broader range of Web servers easily on a broader range of Web servers because ActiveX objects are platform specific.because ActiveX objects are platform specific.

JSP technology adheres to the “Write Once, JSP technology adheres to the “Write Once, Run Anywhere” philosophy of the Java Run Anywhere” philosophy of the Java architecture. Instead of being tied to a single architecture. Instead of being tied to a single platform or vendor, JSP technology can run on platform or vendor, JSP technology can run on any Web server and is supported by a wide any Web server and is supported by a wide variety of tools from multiple vendors.variety of tools from multiple vendors.

Page 13: Introduction to JSP Liu Haibin 2014-10-03

JSP technology uses the Java language for scripting, JSP technology uses the Java language for scripting, while ASP pages use Microsoft VBScript or JScript. while ASP pages use Microsoft VBScript or JScript. The Java language is a mature, powerful, and scalable The Java language is a mature, powerful, and scalable programming language that provides many benefits programming language that provides many benefits

over over the Basic-based scripting languages. the Basic-based scripting languages.

The Java language makes the developer’s job easier in The Java language makes the developer’s job easier in other ways as well. The Java language also helps in other ways as well. The Java language also helps in

the the area of memory management by providing protection area of memory management by providing protection against memory leaks and hard-to-find pointer bugs against memory leaks and hard-to-find pointer bugs that can slow application deployment. Plus, JSP that can slow application deployment. Plus, JSP provides the robust exception handling necessary for provides the robust exception handling necessary for real-world applications.real-world applications.

Page 14: Introduction to JSP Liu Haibin 2014-10-03

ASP Technology JSP Technology

Web ServerMicrosoft IIS or Personal

Web ServerAny web server, including Apache, Netscape, IIS,

Websphere, and Weblogic

Platforms Microsoft Windows (Accessing other platforms

requires third-party ASP porting products.)

Most popular platforms, including the Solaris™ Operating Environment, Microsoft Windows, Mac

OS, Linux, and other UNIX® platform implementations

Reusable, Cross-Platform

Components

No JavaBeans, Enterprise JavaBeans, custom JSP tags

Security Against SystemCrashes

No Yes

Memory Leak Protection

No Yes

Scripting Language VBScript, JavaScript Java

Customizable Tags No Yes

Page 15: Introduction to JSP Liu Haibin 2014-10-03

Only people who are very familiar with JAVA Only people who are very familiar with JAVA can use JSP pretty well. can use JSP pretty well.

Five drawbacksFive drawbacks

JSP program is relatively difficult to debug. JSP program is relatively difficult to debug.

Database connection is not very easy. Many Database connection is not very easy. Many codes are needed.codes are needed.

It is hard to choose proper servlet engine.It is hard to choose proper servlet engine.

There are some other problems during JSP programming. The author of “Java There are some other problems during JSP programming. The author of “Java servlet programming” wrote an interesting paper to compare JSP with other servlet programming” wrote an interesting paper to compare JSP with other substituted tools. Please refer to: substituted tools. Please refer to:

http://www.servlets.com/soapbox/problems-jsp.htmlhttp://www.servlets.com/soapbox/problems-jsp.html

Page 16: Introduction to JSP Liu Haibin 2014-10-03

SummarySummary

I’m crazy about Java.I’m crazy about Java.

I like HTML.I like HTML.+

I love JSP!I love JSP!≡

Page 17: Introduction to JSP Liu Haibin 2014-10-03

ReferenceReference

http://java.sun.com/products/jsp/http://java.sun.com/products/jsp/ ---JSP ---JSP official websiteofficial website

http://www.indiawebdevelopers.com/techhttp://www.indiawebdevelopers.com/technology/java/jspvsasp.aspnology/java/jspvsasp.asp ---JSP vs ASP ---JSP vs ASP

Comparing JavaServer Pages™ Technology and Microsoft Active Server Pages--An Analysis of Functionality

http://www.apl.jhu.edu/~hall/java/Servlet-http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Tutorial/ ---A Tutorial on Java Servlets and Java ---A Tutorial on Java Servlets and Java Server PagesServer Pages

Page 18: Introduction to JSP Liu Haibin 2014-10-03

Thank you Thank you

for your attention!for your attention!