Top Banner
Java Server Pages (JSP) Presented by: Ananth Prasad & Alex Ivanov May 10, 2001
21

Java Server Pages (JSP)

Jan 21, 2016

Download

Documents

spiro

Java Server Pages (JSP). Presented by: Ananth Prasad & Alex Ivanov May 10, 2001. JSP Definition. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Java Server Pages (JSP)

Java Server Pages (JSP)

Presented by:

Ananth Prasad & Alex Ivanov

May 10, 2001

Page 2: Java Server Pages (JSP)

JSP Definition

JSP is a dynamic scripting capability for web JSP is a dynamic scripting capability for web pages that allows java as well as a few pages that allows java as well as a few

special tags to be embedded into a web file special tags to be embedded into a web file (HTML/XML, etc). The suffix traditionally (HTML/XML, etc). The suffix traditionally ends with .Jsp to indicate to the web server ends with .Jsp to indicate to the web server

that the file is a JSP file. JSP is a that the file is a JSP file. JSP is a server sideserver side technologytechnology - can't do any client side - can't do any client side

validation with itvalidation with it

Page 3: Java Server Pages (JSP)

JSP

Page 4: Java Server Pages (JSP)

JSP

• A JSP file is a script like an ASP file except that represents a template for a web page.

• When the page is first requested, the JSP is compiled into a “servlet” form and executed.

• Afterwards the JSP script exists as a compiled java byte-code (unless it is changed)

Page 5: Java Server Pages (JSP)

Why not just write Servlets?

The focus is on HTML. Java and the JSP The focus is on HTML. Java and the JSP extensions assist in making the HTML moreextensions assist in making the HTML morefunctional. Servlets on the other hand allow functional. Servlets on the other hand allow outputting of HTML but it is a tediousoutputting of HTML but it is a tediousprocess. process.

It is easy to make a change and then let the JSP It is easy to make a change and then let the JSP capability of the Web Server you arecapability of the Web Server you areusing deal with compiling it into a Servlet and using deal with compiling it into a Servlet and running it. running it.

Page 6: Java Server Pages (JSP)

JSP

Page 7: Java Server Pages (JSP)

JSP BenefitsEasy and Rapid Web Development, Easy and Rapid Web Development,

Deployment and MaintenanceDeployment and Maintenance

Emphasizing Reusable ComponentsEmphasizing Reusable Components

Separating Content Generation from Separating Content Generation from PresentationPresentation

Page 8: Java Server Pages (JSP)

JSP Benefits Contd.....

Open Development and Widespread Open Development and Widespread Industry SupportIndustry Support

Platform IndependencePlatform Independence

Simplifying Page Development with Simplifying Page Development with TagsTags

Page 9: Java Server Pages (JSP)

Use of Beans

One use of JavaBeans is as a data encapsulator. A property of a JavaBean is simply the data (state) of the bean. Properties are accessible by two methods: the getter and the setter. The value of the property is accessed by the getter method. If the property is writeable, its value is changed by the setter method.

Page 10: Java Server Pages (JSP)

Use of Beans contd.....

Loading a Bean - <jsp:usebean>

Initializing a Bean - <jsp:setProperty>

Displaying Dynamic Content - <jsp:getProperty>

Page 11: Java Server Pages (JSP)

Java code in your page?

Three ways…

• Using declarations, <%!.........%>.

• With scriptlets, <%...........%>.

• Expressions between <%=.....%>.

Page 12: Java Server Pages (JSP)

A look at simple JSP code

<html>

<body>

<b>I’m HTML code.</b><br>

<% out.println(“I’m Java code.”) %>

</body>

</html>

Page 13: Java Server Pages (JSP)

Example, “Hello, World”

Example:<%

String name = null; if (request.getParameter(“name”) == null ) { %> Hello, World<% } else {

println.out(“Hello,” + name); } %>

Page 14: Java Server Pages (JSP)

JSP Vs JavaScript

JavaScript– Validates on Client Side– Less Secure– Browser Dependent– Unstable– ….

Page 15: Java Server Pages (JSP)

JSP Vs. Servlets

Similarities

• Provide identical results to the end user

• JSP is an additional module to the servlet

Page 16: Java Server Pages (JSP)

JSP Vs Servlets contd.....

Differences

• Servlets: “HTML in Java Code”HTML code inaccessible to Graphics designer

But accessible to Programmer

• JSP: “Java Code Scriplets in HTML”HTML code accessible to Graphic Designer

Java code accessible to Programmer

Page 17: Java Server Pages (JSP)

JSP Vs ASP

ASP JSPWeb Server IIS, PWS AnyPlatforms Windows AnyReusable crossplatformcomponents?

No Yes

Security againstSystem Checks

No Yes

CustomizableTags

No Yes

Page 18: Java Server Pages (JSP)

Useful Links of JSP

• The current version of JSP is 1.1. It is available from

http://java.sun.com/products/jsp.

• Archives of the JSP mailing list are available at

http://archives.java.sun.com/archives/jsp-interest.html

• web application servers support JSP

http://www.flashline.com/components/appservermatrix.jsp

• JSP Demo website

http://www.flashline.com/

Page 19: Java Server Pages (JSP)

Conclusion

• JSP is robust server side dynamic web page generator.

• Easy to implement

• Easy to manage

• Code is portable

• Free

Page 20: Java Server Pages (JSP)

References

• Web page development using JSPby Duane K. Fields, Mark A. Kolb

• Java Server Pages -- by Hans Bergsten

• Core Servlets and JSP -- by Marty Hall

• Graphics used on this presentation was obtained from different web sites.

Page 21: Java Server Pages (JSP)

The End