Home>

jsp page element composition

jsp page components are:instructions, comments, static content,Expressions, small scripts, declarations.

jsp instruction

page directive:usually located at the top of a jsp page,There can be multiple page directives on the same page

include directive:Embeds an external file into the current jsp file, while parsing the jsp statements in this page

taglib directive:use the tag library to define new custom tags,Start custom behavior in jsp page

page instruction syntax

jsp annotation

Comments on the jsp page.

html comments:

<!-Html comments->//client visible

jsp's note:

<%-html comment-%>//client is not visible

jsp script comment:

//Single line comment

/**/Multi-line comment

jsp script

Java code executed in jsp page

grammar:

<%java code%>

jsp statement

Define variables or methods in a jsp page

grammar:

<%! Java code%>

jsp expression

Expressions executed in jsp pages

grammar:

<%= expression%>//Note:the expression does not end with a semicolon

jsp page life cycle

The life cycle of jsp is divided into four main phases which are very similar to the life cycle of a servlet,And there are the following points:

jsp compilation:

When the browser requests a jsp, the jsp engine first checks if it needs to compile the page.If the page has never been compiled,Or if jsp has been modified,Because it is the last page compiled by the jsp engine.

The compilation process includes three steps:

•Parse jsp.

•Open jsp into a servlet.

•Compile this servlet.

jsp initialization:

When a container loads a jsp it requests any service before calling the jspinit () method. If you need to perform jsp-specific initialization

jsp executes:

This stage of the jsp life cycle represents all interactions requested,Until jsp is broken.

When the browser requests a jsp and the page has been loaded and initialized,The jsp engine calls the _jspservice () method in jsp.

jsp cleanup:

The life cycle destruction phase of jsp represents the container used when jsp is deleted.

The jspdestroy () method is the destroy method equivalent to the jsp servlet. Override jspdestroy when you need to perform any cleanup,Such as releasing a database connection or closing an open file.

jsp
  • Previous PHP use array_slice function to get random array or first few data
  • Next Modify the default port number of tomcat