Introduction to JSP Elements

Source: Internet
Author: User

Generally, you need to take the file ". jsp" as the extension and place it under any path where you can place a normal web page. Although the JSP file looks more like an HTML file than a Servlet File, in fact, it will be converted to a Servlet File, where the static HTML is only used to output the information returned by the Servlet service method. If JSPpages has been converted to a Servlet and the Servlet is compiled and then loaded at the first Request), when you Request this JSP page again, you will not be able to detect a transient delay. Please pay attention to this phenomenon. Some WebServers allow you to define an alias for it, as if a URL points to an HTML, but in fact it points to a Servlet or JSPpages.

Construct a JSPpage. In addition to embedded rule HTML, there are three main JSP elements: Scriptingelements, Directives, and Actions. with Scriptingelements, you can define the part that is finally converted to Servlet. Directives allows you to control the overall structure of this Servlet, while Actions allows you to specify reusable existing components. In addition, you can also control the running of the JSP Engine. To simplify Scriptingelements, you can take advantage of some predefined variables, such as request.

This tutorial is Based on JSP 1.1. Its syntax is summarized in the following table. Its detailed usage will be explained in detail in subsequent courses.

JSP element syntax
JSP element explanation

JSP Expression

Expression is used for calculation and output.
Expression. The predefined variables that can be used include request, response, out, session, application, config, and andpageContext, which can also be used in Sriptlets ).

JSP Scriptlet

Insert the code for the service.
Code

JSP Declaration

The Servlet code is not a service method.
Code

JSP page Directive

The path to the Servlet engine.
. The following are valid attributes:
Import = "package. class"
ContentType = "MIME-Type"
IsThreadSafe = "true | false"
Session = "true | false"
Buffer = "sizekb | none"
Autoflush = "true | false"
Extends = "package. class"
Info = "message"
ErrorPage = "url"
IsErrorPage = "true | false"
Language = "java"
JSP include Directive

When the JSP page is translated into a Servlet, it will be included in the files on the local system.
This URL must be relative. When the page is requested, call "jsp include action.

JSP comments

When JSP is converted to Servlet, it is ignored.
The JSP include Action

JSP elements are transferred to the file when the page is Requested for Requested.
If you want to include the file when the page is converted to Translated), use the aforementioned direve ve instead. Warning: Servers on some Servers), The contained file can only be HTML or JSP, generally determined by the file extension name.

The jsp: use Bean Action
Or
.....

Find or generate a JavaBean.
Possible attributes are:
Id = "name"
Scope = "page | request | session | application"
Class = "package. class"
Type = "package. class"
BeanName = "package. class"
Thejsp: setProperty Action

Set bean properties by explicitly specifying or using the request parameters.
Valid attributes:
Name = "bean Name"
Property = "property Name | *"
Param = "parameter Name"
Value = "val"
The jsp: getPropertyAction

Retrieves and outputs bean attributes.
The jsp: forward Action

Request) another page.
The jsp: plugin Action

Generate the OBJECT or EMBED tag of a specific browser to specify the JAVA Plug-in used to run the Applet.

  1. Analysis of JSP server
  2. Monitor JVM available memory in JSP
  3. JSP Init and Destory functions improve work efficiency
  4. Basic JSP compiler syntax
  5. Analysis on compiling JSP tags

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.