Download presentation
Presentation is loading. Please wait.
Published byEdmund Perkins Modified over 9 years ago
1
An Introduction to JavaServer™ Pages Prepared by Nicole Swan
2
General JSP Information Most Common JSP Components –Static HTML/XML components –Special JSP tags –Optionally, snippets of code written in Java called “scriptlets” JSPs are parsed on the server side –Translation phase occurs only once unless JSP is updated –Compiled class is then served to each client upon request
3
Advantages of JSP Separation of static from dynamic content Write once run anywhere Dynamic content can be served in a variety of formats Recommended web access layer for n-tier architecture Completely leverages the Servlet API (Source: http://developer.java.sun.com/developer/onlineTraining/JSPIntro/contents.html )http://developer.java.sun.com/developer/onlineTraining/JSPIntro/contents.html
4
JSP vs. ASP (Source: http://developer.java.sun.com/developer/onlineTraining/JSPIntro/contents.html )http://developer.java.sun.com/developer/onlineTraining/JSPIntro/contents.html JSPASP Web Server Support Most popular web servers including Apache, Netscape, Microsoft IIS. Native support only within Microsoft IIS or Personal Web Server. Platform Support Platform independent. Runs on all Java-enabled platforms. Is fully supported under Windows. Component Model Reusable, cross-platform components like JavaBeans, EJB, and custom tag libraries. Uses the Win32-based COM component model. ScriptingJava or JavaScript. Supports VBScript and JScript for scripting. SecurityJava security model. Windows NT security architecture. Database AccessJDBC Active Data Objects Customizable Tags Extensible with custom tag libraries. Not extensible and cannot use custom tag libraries.
5
Basic JSP Syntax Directives Declarations Expressions Comments Scriptlets
6
Directives page directives are found at the top of most JSP pages. Specify java packages to include, the page language type, or the content type. Examples
7
Directives include directives are used to include static html content or other JSP content. Example
8
Declarations Declarations are found within the tag. Anything within this tag must be valid Java code including all appropriate syntax. Example <%! public void foo(){ out.println( i ); } %>
9
Expressions With expressions, the result of evaluating the expression is directly included in the output of the JSP page. Examples
10
Comments JSP comments are enclosed in the tag. Any comments in this format are not viewable when viewing the page’s source in a browser. Example Note: Can still use HTML comments though they are viewable to client
11
Scriptlets Scriptlets are used to embed code fragments within a JSP page. The tag is used. Example ”>
12
JSP Tag Libraries Allow Java developers to decouple static HTML and complex server-side behaviors In a sense, are a replacement for scriptlets Required use by many companies in JSP development Example true Condition was true Condition was false
13
JavaBeans JavaBeans topic is broad and complex For our purposes, allow JSP developers to decouple static HTML and complex server- side behaviors through the use of classes
14
Web Servers/Servlet Containers Apache Tomcat (Open Source) –http://jakarta.apache.org/tomcat/http://jakarta.apache.org/tomcat/ Jetty (Open Source) –http://jetty.mortbay.org/jetty/index.htmlhttp://jetty.mortbay.org/jetty/index.html Bajie (free) –http://www.geocities.com/gzhangx/websrv/http://www.geocities.com/gzhangx/websrv/ –Created by student at University of Texas – Dallas Various third-party servlet containers for various web servers –http://java.sun.com/products/servlet/industry.htmlhttp://java.sun.com/products/servlet/industry.html
15
Additional Resources JSP Tutorial –http://developer.java.sun.com/developer/onlineTraining/JSPIntro/http://developer.java.sun.com/developer/onlineTraining/JSPIntro/ Java Developer Connection –http://forum.java.sun.com/http://forum.java.sun.com/ JavaServer™ Pages –http://java.sun.com/products/jsp/http://java.sun.com/products/jsp/ JSP Syntax Reference –http://java.sun.com/products/jsp/technical.html#syntaxhttp://java.sun.com/products/jsp/technical.html#syntax Google
16
Questions & Comments?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.