Misplaced Pages

Jakarta Server Pages

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

Jakarta Server Pages ( JSP ; formerly JavaServer Pages ) is a collection of technologies that helps software developers create dynamically generated web pages based on HTML , XML , SOAP , or other document types. Released in 1999 by Sun Microsystems , JSP is similar to PHP and ASP , but uses the Java programming language .

#791208

29-434: To deploy and run Jakarta Server Pages, a compatible web server with a servlet container , such as Apache Tomcat or Jetty , is required. Architecturally, JSP may be viewed as a high-level abstraction of Jakarta Servlets . JSPs are translated into servlets at runtime, therefore JSP is a Servlet; each JSP servlet is cached and re-used until the original JSP is modified. Jakarta Server Pages can be used independently or as

58-452: A document. The compiled pages, as well as any dependent Java libraries, contain Java bytecode rather than machine code . Like any other .jar or Java program, code must be executed within a Java virtual machine (JVM) that interacts with the server's host operating system to provide an abstract, platform-neutral environment. JSPs are usually used to deliver HTML and XML documents, but through

87-522: A longer interval (perhaps minutes, or even never) for a deployed Web application . According to Joel Murach and Michael Urban, authors of the book "Murach's Java Servlets and JSP", embedding Java code in JSP is generally bad practice. A better approach would be to migrate the back-end logic embedded in the JSP to the Java code in the Servlet . In this scenario, the Servlet is responsible for processing, and

116-462: A note to his site saying that JSP had improved since 2000, but also cited its competitors, Apache Velocity and Tea (template language). Today, several alternatives and a number of JSP-oriented pages in larger web apps are considered to be technical debt. Servlet container A web container (also known as a servlet container; and compare "webcontainer" ) is the component of a web server that interacts with Jakarta Servlets . A web container

145-461: A single unified expression language (EL 2.1). Version 3.0 of the expression language (the unified was no longer deemed necessary) was developed in a JSR independent of the JSP and JSF specifications in JSR-341 . Some new features were added, most notably EL equivalents of Java 8 streams and lambda expressions . Version 4.0 was released in on 2020-10-07. The API moved from the javax.el package to

174-823: A unified expression language which was first included in the JSP 2.1 specification (JSR-245), and later specified by itself in JSR-341, part of Java EE 7. The expression language started out as part of the JavaServer Pages Standard Tag Library (JSTL) and was originally called SPEL (Simplest Possible Expression Language), then just Expression Language ( EL ). It was a scripting language which allowed access to Java components ( JavaBeans ) through JSP . Since JSP 2.0 , it has been used inside JSP tags to separate Java code from JSP, and to allow easier access to Java components (than in Java code). Over

203-554: Is a stub . You can help Misplaced Pages by expanding it . Unified Expression Language The Jakarta Expression Language ( EL ; formerly Expression Language and Unified Expression Language ) is a special purpose programming language mostly used in Jakarta EE web applications for embedding and evaluating expressions in web pages. The specification writers and expert groups of the Java EE web-tier technologies have worked on

232-440: Is a fragment of Java code that runs when the user requests the page. Other common delimiters include <%= ... %> for expressions, where the scriptlet and delimiters are replaced with the result of evaluating the expression, and directives , denoted with <%@ ... %> . Java code is not required to be complete or self-contained within a single scriptlet block. It can straddle markup content, provided that

261-545: Is responsible for managing the lifecycle of servlets, mapping a URL to a particular servlet and ensuring that the URL requester has the correct access-rights. A web container handles requests to servlets , Jakarta Server Pages (JSP) files, and other types of files that include server-side code. The Web container creates servlet instances, loads and unloads servlets, creates and manages request and response objects, and performs other servlet-management tasks. A web container implements

290-677: Is the JSTL . Jakarta Standard Tag Library (JSTL) supports common tasks that must be performed in JSPs. Examples includes iteration and conditionals (the equivalent of "for" and "if" statements in Java). Out of all the libraries in JSTL, the JSTL core library is most commonly used. A taglib directive must be used to specify the URI of the JSTL core library using a prefix. Although there are many different choices for

319-428: Is then written between the opening and closing braces. The following is an example of EL syntax : The value of variable in the object javabean is $ {javabean.variable} . The JSP syntax add additional tags, called JSP actions, to invoke built-in functionality. Additionally, the technology allows for the creation of custom JSP tag libraries that act as extensions to the standard JSP syntax. One such library

SECTION 10

#1732780539792

348-470: Is used to set the properties for a bean. For the getProperty and setProperty tags, the name attribute is used to specify the bean's name. So the name attribute must match the id attribute provided by the useBean tag. Version 2.0 of the JSP specification added support for the Expression Language (EL), used to access data and functions in Java objects. In JSP 2.1, it was folded into

377-423: The useBean tag looks similar to an HTML tag, all JSP tags for JavaBeans use XML syntax. Therefore the code containing the useBean tag is case-sensitive. The useBean tag contains several attributes. The id attribute declares the name that is used for gaining access to the bean. The class attribute declares the package and class for the bean. The scope declares the object responsible for storing

406-552: The Unified Expression Language , which is also used in JavaServer Faces . The JSP Expression Language uses a compact syntax which enables the developer to get attributes and JavaBean properties from a given request object. When using EL, a dollar sign ("$ ") must be added at the beginning of the code. The dollar symbol is followed by an opening brace ("{"), as well as a closing brace ("}"). The code

435-553: The JSP is responsible for displaying the HTML, maintaining a clear separation of concerns . In 2000, Jason Hunter, author of "Java Servlet Programming" described a number of "problems" with JavaServer Pages. Nevertheless, he wrote that while JSP may not be the "best solution for the Java Platform" it was the "Java solution that is most like the non-Java solution," by which he meant Microsoft's Active Server Pages . Later, he added

464-448: The bean. The value for the scope defines the duration for which the bean is available for the rest of the java application to use. The scope can be one of the following four values: After a bean has been created using the useBean tag, the getProperty and setProperty tags can be used for getting and setting the properties of the bean. The JSP getProperty is used to get the property of created bean. The JSP setProperty tag

493-442: The common <%@ page .. %> directive may instead be written as a <jsp:directive.page .. /> tag, and tag libraries are imported using XML namespaces , instead of the usual <%@ taglib .. %> tag. A JavaServer Pages compiler is a program that parses JSPs and transforms them into executable Java Servlets . A program of this type is usually embedded into the application server and run automatically

522-476: The development of JSP 2.0, the JavaServer Faces technology was released which also needed an expression language, but the expression language defined in the JSP 2.0 specification didn't satisfy all the needs for development with JSF technology. The most obvious limitations were that its expressions were evaluated immediately, and the JSF components could not invoke methods on server-side objects. A more powerful language

551-400: The first time a JSP is accessed, but pages may also be precompiled for better performance, or compiled as a part of the build process to test for errors. Some JSP containers support configuring how often the container checks JSP file timestamps to see whether the page has changed. Typically, this timestamp would be set to a short interval (perhaps seconds) during software development , and

580-403: The jakarta.el package, as part of the transition from Java EE to Jakarta EE. Part of Jakarta EE 9. Version 5.0 was released in on 2022-09-05. Removal of a long deprecated method, clarified ambiguities in the specification, added small usability enhancements. Part of Jakarta EE 10. The unified EL is a union of the JSP and JSF expression languages. In addition to the features already available in

609-400: The output when the if condition evaluates to true. Likewise, content inside a loop construct may appear multiple times in the output, depending upon how many times the loop body runs. The following would be a valid for loop in a JSP page: The output displayed in the user's web browser would be: The JSP useBean tag enables the developer to access and create a Javabean. Although using

SECTION 20

#1732780539792

638-439: The page as a whole is syntactically correct. For example, any Java if/for/while blocks opened in one scriptlet must be correctly closed in a later scriptlet for the page to successfully compile. This allows code to be intermingled and can result in poor programming practices. Content that falls inside a split block of Java code (spanning multiple scriptlets) is subject to that code. Content inside an if block will only appear in

667-454: The prefix, the "c" prefix is commonly used for this library. JSP pages may also be written in fully valid XML syntax. Such JSP files commonly use the alternative .jspx file extension, which usually causes the application server to validate the XML syntax. Since the usual JSP syntax <% ... %> is not valid in XML, a developer must use alternative tags provided by JSP. For example,

696-420: The use of OutputStream, they can deliver other types of data as well. The Web container creates JSP implicit objects like request, response, session, application, config, page, pageContext, out and exception. JSP Engine creates these objects during translation phase. JSPs use several delimiters for scripting functions. The most basic is <% ... %> , which encloses a JSP scriptlet. A scriptlet

725-413: The view component of a server-side model–view–controller design, normally with JavaBeans as the model and Java servlets (or a framework such as Apache Struts ) as the controller. This is a type of Model 2 architecture. JSP allows Java code and certain predefined actions to be interleaved with static web markup content, such as HTML. The resulting page is compiled and executed on the server to deliver

754-548: The web component contract of the Jakarta EE architecture. This architecture specifies a runtime environment for additional web components, including security , concurrency , lifecycle management , transaction , deployment, and other services. The following is a list of notable applications which implement the Jakarta Servlet specification from Eclipse Foundation , divided depending on whether they are directly sold or not. This computer networking article

783-436: The years, the expression language has evolved to include more advanced functionality and it was included in the JSP 2.0 specification. Scripting was made easier for web-content designers who have little or practically no knowledge of the core Java Language. This scripting language made JSP a scripting language in the true sense. Before EL, JSP consisted of some special tags like scriptlets , expressions etc. within which Java code

812-524: Was created with the following new features: The new expression language worked well for the purposes of JSF. But developers had problems when integrating the JSP EL with the JSF EL because of conflicts. Because of these incompatibilities, the unified expression language initiative was started to unify these expression languages. As of JSP 2.1, the expression languages of JSP 2.0 and JSF 1.1 have been merged into

841-503: Was written explicitly. With EL the web-content designer needs only to know how to make proper calls to core Java methods. EL was, both syntactically and semantically, similar to JavaScript expressions: EL also liberated the programmer from having to know the particularities of how the values are actually accessed: object.property can mean (depending on what the object is) either object.get("property") or object.getProperty("property") or object.getProperty() etc. During

#791208