Photo:1 Photo:2 Photo:3 Photo:4 |
| Overview | |
| 2>
Architecturally, JSP may be viewed as a high-level abstraction of Java servlets. JSPs are loaded in the server and are operated from a structured special installed Java server packet called a Java EE Web Application, often packaged as a file archive.
JSP allows Java code and certain pre-defined actions to be interleaved with static web markup content, with the resulting page being compiled and executed on the server to deliver an HTML or XML document. The compiled pages and any dependent Java libraries use Java bytecode rather than a native software format, and must therefore be executed within a Java virtual machine (JVM) that integrates with the host operating system to provide an abstract platform-neutral environment.
JSP syntax is a fluid mix of two basic content forms: scriptlet elements and markup. Markup is typically standard HTML or XML, while scriptlet elements are delimited blocks of Java code which may be intermixed with the markup. When the page is requested the Java code is executed and its output is added, in situ, with the surrounding markup to create the final page. JSPs must be compiled to Java bytecode classes before they can be executed, but such compilation is needed only when a change to the source JSP file has occurred.
Java code is not required to be complete (self contained) within its scriptlet element block, but can straddle markup content providing the page as a whole is syntactically correct (for example, any Java if/for/while blocks opened in one scriptlet element must be correctly closed in a later element for the page to successfully compile). This system of split inline coding sections is called step over scripting because it can wrap around the static markup by stepping over it. Markup which falls inside a split block of code is subject to that code, so markup inside an if block will only appear in the output when the if condition evaluates to true; likewise markup inside a loop construct may appear multiple times in the output depending upon how many times the loop body runs.
The JSP syntax adds additional XML-like tags, called JSP actions, to invoke built-in functionality. Additionally, the technology allows for the creation of JSP tag libraries that act as extensions to the standard HTML or XML tags. JVM operated tag libraries provide a platform independent way of extending the capabilities of a web server. Note that not all commercial Java servers are Java EE specification compliant.[which?]
Starting with version 1.2 of the JSP specification, JavaServer Pages have been developed under the Java Community Process. JSR 53 defines both the JSP 1.2 and Servlet 2.3 specifications and JSR 152 defines the JSP 2.0 specification. As of May 2006 the JSP 2.1 specification has been released under JSR 245 as part of Java EE 5. As of Dec 10, 2009 the JSP 2.2 specification has been released as a maintenance release of JSR 245.
[edit] Tags:Java,Html,Xml,Edit,Java Servlets,Java Virtual Machine,Operating System,Scriptlet,In Situ,Platform Independent,Web Server,Java Community Process,Java Ee,Servlets,Java Servlet, | |
| Example | |
| 2>
JSPs are compiled into servlets by a JSP compiler. The compiler either generates a servlet in Java code that is then compiled by the Java compiler, or it may compile the servlet to byte code which is directly executable. JSPs can also be interpreted on-the-fly, reducing the time taken to reload changes.
Regardless of whether the JSP compiler generates Java source code for a servlet or emits the byte code directly, it is helpful to understand how the JSP compiler transforms the page into a Java servlet. For example, consider the following input JSP and its resulting generated Java Servlet.
Input JSP
<%@ page errorPage="myerror.jsp" %>
<%@ page import="com.foo.bar" %>
<html>
<head>
<%! int serverInstanceVariable = 1;%>
<% int localStackBasedVariable = 1; %>
<table>
<tr><td><%= toStringOrBlank( "expanded inline data " + 1 ) %></td></tr>
Resulting servlet
package jsp_servlet;
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import com.foo.bar; // Imported as a result of <%@ page import="com.foo.bar" %>
import …
class _myservlet implements javax.servlet.Servlet, javax.servlet.jsp.HttpJspPage {
// Inserted as a
// result of <%! int serverInstanceVariable = 1;%>
int serverInstanceVariable = 1;
…
public void _jspService( javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response )
throws javax.servlet.ServletException,
java.io.IOException
{
javax.servlet.ServletConfig config = …; // Get the servlet config
Object page = this;
PageContext pageContext = …; // Get the page context for this request
javax.servlet.jsp.JspWriter out = pageContext.getOut();
HttpSession session = request.getSession( true );
try {
out.print( "<html>\r\n" );
out.print( "<head>\r\n" );
…
// From <% int localStackBasedVariable = 1; %>
int localStackBasedVariable = 1;
…
out.print( "<table>\r\n" );
out.print( " <tr><td>" );
// From <%= toStringOrBlank( "expanded inline data " + 1 ) %>
out.print( toStringOrBlank( "expanded inline data " + 1 ) );
out.print( " </td></tr>\r\n" );
…
} catch ( Exception _exception ) {
// Clean up and redirect to error page in <%@ page errorPage="myerror.jsp" %>
}
}
}
[edit] Tags:Jsp Compiler,Byte Code,Interpreted,Help, | |
| JSP 2.0 | |
| 2>
The new version of the JSP specification includes new features meant to improve programmer productivity. Namely:
An Expression Language (EL) which allows developers to create Velocity-style templates (among other things).
A faster/easier way to display parameter values.
A clear way to navigate nested beans.
The Java EE 5 Platform has focused on easing development by making use of Java language annotations that were introduced by J2SE 5.0. JSP 2.1 supports this goal by defining annotations for dependency injection on JSP tag handlers and context listeners.
Another key concern of the Java EE 5 specification has been the alignment of its web tier technologies, namely JavaServer Pages (JSP), JavaServer Faces (JSF), and the JavaServer Pages Standard Tag Library (JSTL).
The outcome of this effort has been the Unified Expression Language (EL), which integrates the expression languages defined by JSP 2.0 and JSF 1.1.
The main key additions to the Unified EL that came out of the alignment work have been: A pluggable API for resolving variable references into Java objects and for resolving the properties applied to these Java objects, support for deferred expressions, which may be evaluated by a tag handler when needed, unlike their regular expression counterparts, which get evaluated immediately when a page is executed and rendered, and support for l-value expression, which appear on the left hand side of an assignment operation. When used as an l-value, an EL expression represents a reference to a data structure, for example: a JavaBeans property, that is assigned some user input. The new Unified EL is defined in its own specification document, which is delivered along with the JSP 2.1 specification.
Thanks to the Unified EL, JSTL tags, such as the JSTL iteration tags, can now be used with JSF components in an intuitive way.
JSP 2.0 introduced a problem in the tag library section on how the JSP version information was represented. The specification itself is inconsistent, sometimes referring to a jsp-version element, and at other times a version attribute on the root element. JSF specifications have gone with the later interpretation; however some JSP implementations still expect the jsp-version element.
JSP 2.1 leverages the Servlet 2.5 specification for its web semantics.
[edit] Tags:Improve,Expression Language,Velocity,Templates,Javaserver Faces,Javaserver Pages Standard Tag Library,Unified Expression Language,Jstl, | |
| See also | |
| 2>
Java portal
Apache Tomcat
Apache Velocity
ASP.NET
CFM
EAR (file format)
FreeMarker
GSP
JAR (file format)
Java Servlet
JHTML
JSTL
PHP
Python Server Pages
Sun Java System Web Server
Thymeleaf
WAR (Sun file format)
[edit] Tags:Asp,Php,Java Portal,Apache Tomcat,Apache Velocity,Asp.net,Cfm,Ear (file Format),Freemarker,Gsp,Jar (file Format),Jhtml,Python Server Pages,Sun Java System Web Server,Thymeleaf,War (sun File Format), | |
| Further reading | |
| 2>
Bergsten, Hans (2003). JavaServer Pages (3rd Edition ed.). O'Reilly Media. ISBN 978-0-596-00563-4.
Hanna, Phil. JSP 2.0 - The Complete Reference. McGraw-Hill Osborne Media. ISBN 978-0-072-22437-5.
Kathy, Sierra; Bert Bates & Bryan Basham. Head First Servlets & JSP. O'Reilly Media. ISBN 978-0-596-00540-5.
Brown, Simon; Sam Dalton, Daniel Jepp, Dave Johnson, Sing Li, and Matt Raible. Pro JSP 2. Apress. ISBN 1-59059-513-0.
[edit] Tags:O'reilly Media,Mcgraw-hill Osborne Media,Apress, | |
| External links | |
| 2>
Wikibooks has a book on the topic of
Java Programming/JSP
JSR 245 (JSP 2.1)
JSR 152 (JSP 2.0)
JSR 53 (JSP 1.2)
JSP 1.1 and 1.0
JSP tutorials with source code
JSP training courses Public courses co-sponsored by Johns Hopkins University, or customized onsite versions
Official tutorial: The Java EE 5 Tutorial, Chapter 5, JavaServer Pages Technology
JavaServer Pages (JSP) v1.2 Syntax Reference, [1], v2.0
JAVASERVER PAGESª (JSPª) SYNTAX version 1.2, version 2.0
v
d
e
Java
Java platform
Java language · JVM · Micro Edition · Standard Edition · Enterprise Edition · Java Card
Sun technologies
Squawk · Java Development Kit · OpenJDK · Java virtual machine · JavaFX · Maxine VM
Platform technologies
Applets · Servlets · MIDlets · jsp · Web Start (jnlp)
Major third-party technologies
JRockit · GNU Classpath · Kaffe · TopLink · Apache Harmony · Apache Struts · Spring framework · Hibernate · JBoss application server · Tapestry · Jazelle
History
Java version history · Java Community Process · Sun Microsystems · Free Java implementations
Major programming languages
BeanShell · Clojure · Groovy · Oxygene · Java Tcl · JRuby · Jython · Processing · Rhino · Scala · more…
Java conferences
JavaOne
Retrieved from "http://en.wikipedia.org/w/index.php?title=JavaServer_Pages&oldid=458970001"
Categories: Java enterprise platformJava specification requestsTemplate enginesHidden categories: Articles lacking in-text citations from November 2007All articles lacking in-text citationsWikipedia articles needing reorganization from November 2007All articles with unsourced statementsArticles with unsourced statements from October 2010All articles with specifically marked weasel-worded phrasesArticles with specifically marked weasel-worded phrases from May 2010
Personal tools
Log in / create account
Namespaces
Article
Talk
Variants
Views
Read
Edit
View history
Actions
Search
Navigation
Main page
Contents
Featured content
Current events
Random article
Donate to Wikipedia
Interaction
Help
About Wikipedia
Community portal
Recent changes
Contact Wikipedia
Toolbox
What links here
Related changes
Upload file
Special pages
Permanent link
Cite this page
Print/export
Create a bookDownload as PDFPrintable version
Languages
العربية
Català
Dansk
Deutsch
Español
Esperanto
فارسی
Français
Galego
한국어
हिन्दी
Hrvatski
Bahasa Indonesia
Italiano
עברית
Latviešu
Lietuvių
Magyar
മലയാളം
Nederlands
日本語
Norsk (bokmål)
Norsk (nynorsk)
Polski
Português
Русский
Simple English
Slovenčina
Slovenščina
Suomi
Svenska
தமிழ்
తెలుగు
ไทย
Türkçe
Українська
Tiếng Việt
中文
This page was last modified on 4 November 2011 at 13:40.
Text is available under the Creative Commons Attribution-ShareAlike License;
additional terms may apply.
See Terms of use for details.
Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.Contact us
Privacy policy
About Wikipedia
Disclaimers
Mobile view
if ( window.isMSIE55 ) fixalpha();
if ( window.mediaWiki ) {
mw.loader.load(["mediawiki.user", "mediawiki.util", "mediawiki.page.ready", "mediawiki.legacy.wikibits", "mediawiki.legacy.ajax", "mediawiki.legacy.mwsuggest", "ext.gadget.wmfFR2011Style", "ext.vector.collapsibleNav", "ext.vector.collapsibleTabs", "ext.vector.editWarning", "ext.vector.simpleSearch", "ext.UserBuckets", "ext.articleFeedback.startup", "ext.articleFeedbackv5.startup", "ext.markAsHelpful"]);
}
if ( window.mediaWiki ) {
mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":1,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"highlightbroken":1,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":false,"showjumplinks":1,"shownumberswatching":1,"showtoc":1,"showtoolbar":1,"skin":"vector","stubthreshold":0,"thumbsize":4,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":1,"watchdefault":0,"watchdeletion":0,"watchlistdays":3,"watchlisthideanons":0,
"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"flaggedrevssimpleui":1,"flaggedrevsstable":0,"flaggedrevseditdiffs":true,"flaggedrevsviewdiffs":false,"vector-simplesearch":1,"useeditwarning":1,"vector-collapsiblenav":1,"usebetatoolbar":1,"usebetatoolbar-cgd":1,"wikilove-enabled":1,"variant":"en","language":"en","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"searchNs100":false,"searchNs101":false,"searchNs108":false,"searchNs109":false,"gadget-wmfFR2011Style":1});;mw.user.tokens.set({"editToken":"+\\","watchToken":false});;mw.loader.state({"user.options":"ready","user.tokens":"ready"});
/* cache key: enwiki:resourceloader:filter:minify-js:4:b41a86ec4e0fe8329bc3ce917e792339 */
}
Tags:Java Card,Maxine Vm,Web Start (jnlp),Jazelle,Free Java Implementations,More…,Javaone,Categories,Java Enterprise Platform,Java Specification Requests,Template Engines,Articles Lacking In-text Citations From November 2007,All Articles Lacking In-text Citations,Wikipedia Articles Needing Reorganization From November 2007,All Articles With Unsourced Statements,Articles With Unsourced Statements From October 2010,All Articles With Specifically Marked Weasel-worded Phrases,Articles With Specifically Marked Weasel-worded Phrases From May 2010,Log In / Create Account, | |
zote monety |