Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of JSP element

Shulou Source: shulou.com Published: 2022-06-02 12:31:07 09月20日 Update

Editor to share with you the example analysis of JSP elements, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Typically, you want to put the file with the extension ".jsp" and place it under any path where you can place a normal WEB page. Although the JSP file looks more like a HTML file than an 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 Servlet and Servlet is compiled and then loaded (when it is Request * * times), you will not notice a momentary delay when you Request the JSP page again. Also note that some WebServers allow you to define aliases for it, so that it is as if a URL points to a HTML, but in fact it points to a Servlet or JSPpages.

To construct a JSPpage, in addition to the embeddable regular HTML, there are three main types of JSP elements: Scriptingelements,Directives, and Actions. With Scriptingelements you can define the parts that are eventually converted to Servlet, Directives gives you control over the overall structure of the Servlet, and Actions allows you to specify existing components that are reusable, as well as control the operation of the JSP engine. To simplify Scriptingelements, you can take advantage of some predefined variables, such as request, on a paragraph.

JSP Expression

Expression is used for calculation and output.

Expressions, predefined variables that can be used are request,response,out,session,application,config,andpageContext (which can also be used in Sriptlets).

JSP Scriptlet

Insert the code for the service.

Code

JSP Declaration

Code that belongs to the Servlet section but is not a service method.

Code

JSP page Directive

The path to the Servlet engine.

. The following are its legal 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

A file on the local system that will be included when JSP page is translated into Servlet.

This URL must be relative. Call in with "jsp include action" only when the page is requested.

JSP comment

Will be ignored when JSP is converted to Servlet.

The JSP include Action

The JSP element calls into the file when the page is requested (Requested).

If you want to include the file when the page is Translated, use the directive mentioned above instead. Warning: on some servers (Servers), the included file can only be HTML or JSP, which is generally determined by the suffix name of the file.

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 the properties of bean by explicitly specifying or using the parameters obtained by request.

Legal attribute:

Name= "bean Name"

Property= "property Name | *"

Param= "parameter Name"

Value= "val"

The jsp:getPropertyAction

Retrieve and output the properties of the bean.

The jsp:forward Action

Request forward (request) another page

The jsp:plugin Action

Generate OBJECT or EMBED tags for specific browsers to identify the JAVA plug-ins used to run Applet

The above is all the content of the article "sample Analysis of JSP elements". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: File page attribute element code service point article output example analysis legal fact fact content variable engine method package path Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Docker Shulou Information MySQL vpn