JavaServer Pages (JSP) is a technology that helps software developers create dynamically generated web pages based on HTML

,XML, or other document types. Released in 1999 by Sun [1] Microsystems, JSP is similar to PHP, but it uses the Java programming language. To deploy and run JavaServer Pages, a compatible web server with a servlet container, such as Apache Tomcat or Jetty, is required.
Contents
[hide]

 

1 Overview 2 Syntax

o o     

2.1 Expression Language 2.2 Additional tags

3 Compiler 4 Comparison with similar technologies 5 Caching to improve performance 6 Criticism 7 See also

o o   

7.1 Servlet containers 7.2 Java-based alternatives

8 References 9 Further reading 10 External links

Overview [edit]

and directives. %>.. i<4. Other common delimiters include <%= . For example.. The Web container creates JSP implicit objects like pageContext. markup inside a loop construct may appear multiple times in the output depending upon how many times the loop body runs. each JSP's servlet is cached and re-used until the original JSP is modified.</p> <% } %> <p>Done counting. session. The following would be a valid for loop in a JSP page: <p>Counting to three:</p> <% for (int i=1. Markup which falls inside a split block of code is subject to that code. likewise. so markup inside an if block will only appear in the output when the if condition evaluates to true. The compiled pages. but can straddle markup content providing the page as a whole is syntactically correct. they [4] can deliver other types of data as well. servletContext.. This is a type of Model 2 architecture. A scriptlet is a fragment of Java code that is run when the user requests the page. Syntax [edit] JSP pages use several delimiters for scripting functions. request & response. %>. which encloses a JSP scriptlet.. normally with JavaBeans as the model and Java servlets (or a framework such as Apache Struts) as the [3] controller. use Java bytecode rather than a native software format. Java code is not required to be complete or self-contained within its scriptlet element block. where the value of the expression is placed into [5] the page delivered to the user.. denoted with <%@ . Architecturally. Like any other Java program. %> for expressions. JSPs are translated [2] into servlets at runtime. i++) { %> <p>This number is <%= i %>. but through the use of OutputStream. JSP allows Java code and certain pre-defined actions to be interleaved with static web markup content. The most basic is <% .</p> The output displayed in the user's web browser would be: Counting to three: . JSPs are usually used to deliver HTML and XML documents. with the resulting page being compiled and executed on the server to deliver a document.. JSP can be used independently or as the view component of a server-side model–view–controller design.The JSP Model 2 architecture. JSP may be viewed as a high-level abstraction of Java servlets. they must be executed within a Java virtual machine (JVM) that integrates with the server's host operating system to provide an abstract platform-neutral environment. as well as any dependent Java libraries. 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 timestamp would be set to a short interval (perhaps seconds) during software development. In JSP 2. with support for common tasks such as iteration and conditionals (the [8] equivalent of "if" and "for" statements in Java. and transforms them into executable Java Servlets. which can be used alone. However.0 of the JSP specification added support for the Expression Language (EL). but pages may also be precompiled for better performance. or even never) for a [10] deployed Web application. or with a framework such as Apache Struts. Done counting. PHP is itself a [11] programming language.NET Web Forms. which is also used in JavaServer Faces. A program of this type is usually embedded into the application server and run automatically the first time a JSP is accessed. all three terms refer to a different component of the system. Some JSP containers support configuring how often the container checks JSP file timestamps to see whether the page has changed. This number is 2. An example of EL syntax: The value of "variable" in the object "javabean" is ${javabean. One such library is the JSTL. it was folded [6] into the Unified Expression Language.variable}. For more examples. Additionally.net is a . designed for dynamic Web pages. called JSP actions.) Compiler [edit] A JavaServer Pages compiler is a program that parses JSPs. Typically. used to access data and functions in Java objects. Expression Language [edit] Version 2. the technology allows for the creation of custom JSP tag [7] libraries that act as extensions to the standard JSP syntax. Additional tags [edit] The JSP syntax adds additional tags.1. ASP. see Java Programming/JSP at Wikibooks. and a longer interval (perhaps minutes. or compiled as a part of the [9] build process to test for errors. in that all three add server-side code to an HTML page.This number is 1. Comparison with similar technologies [edit] JSP pages are similar to PHP pages and ASP. This number is 3. JSP refers to the JSP pages. to invoke built-in [5] functionality. with Java servlets.

Criticism [edit] In 2000. the databaseserver cannot. ASP. but also cited its competitors. Jason Hunter criticized JSP for either tempting or requiring the programmer to mix Java code and HTML markup. he added a note to his site saying that JSP had improved since 2000. this is causing performance bottlenecks as you try to add more users and transaction load on your JavaServer Pages application. This results in limited scalability at the data tier. Apache [13] Velocity and Tea. Later. JavaServer Pages application can scale very nicely to multiple web servers. Caching to improve performance [edit] The popularity of JavaServer Pages has meant that it is being used quite frequently in developing high-traffic web apps. You can remove these JavaServer Pages Servlets performance bottlenecks by using adistributed cache for storing the frequently used data. See also [edit] Java portal     JavaServer Faces JavaServer Pages Standard Tag Library (JSTL) EL expressions Java EE version history Servlet containers [edit]    Apache Tomcat Jetty (web server) Oracle iPlanet Web Server Java-based alternatives [edit]  Apache Velocity . Although. While JSP pages use the Java language. while PHP and Java server technologies (including JSP) are fairly operating system agnostic. ASP.framework comparable to Struts or JavaServer Faces that uses pages called Web [12] Forms. The main reason for the database becoming a bottleneck is that while you can add more and more servers to the JavaServer Pages application server farm. although he acknowledged it would "wean people off" of Microsoft's Active Server Pages.NETcompatible language.NET pages can use any .NET is designed for a Microsoft Windows web server. And. you cannot do the same at the database tier. usually C#.

    FreeMarker JHTML Thymeleaf Adobe ColdFusion .

Sign up to vote on this title
UsefulNot useful