JSP file elements

Source: Internet
Author: User
Tags comments expression flush include numeric value
JS 1. Template elements

A. refers to static html/xml content

2. Note

N HTML Comments: displaying annotations <!--comment[<%=expression%>]--> on the client

N Hide comments: Write in JSP program, but not to customer <%--commnet--%>

3. Scripting elements

A. Statement (Declaration)

n declaration is the declaration of legal variables and methods in the JSP program

Eg.1-1

<%! String GetDate ()

{

return new Java.util.Date (). toLocaleString ();

}

int count=10;

%>

B. Expressions (Expression)

An n expression is the code between <%= and%>.

C. Scriptlets

n lies between <% and%>. is the legitimate Java code.

4. Directive elements

A. Page directives

N-Format <%page attribute= "value" ...%>

Property
Describe
Default value
Example

Language
Define the scripting language to use, which is currently only "Java"
Java
Language= "Java"

Import
As with normal Java import, use "," to separate packages or class lists
Default Ignore
Import= "java.io.*,javax.servlet.jsp.*"

Session
Specifies whether this page participates in an HTTP session
True
Session= "true"

Buffer
Specifies the buffer mode to the customer output stream, if none, does not buffer, and if specified numeric value, then the output is not less than the buffer of this value to buffer
No less than 8K, depending on the server can be set
Buffer= "64KB"

Autoflash
True buffer is full, the client output is refreshed, false buffer is full, and a running exception appears, indicating a buffer overflow
True
Autoflash= "true"

Info
For information about JSP pages, define a string that you can use Servlet.getservletinfo () to get
Default Ignore
info= "a test page"

Iserrorpage
Indicates whether the current page is a errorpage target for another page. If set to True, the exception object can be used. Conversely, if it is set to False, the exception object cannot be used.
False
Iserrorpage= "false"

ErrorPage
Define the page that is called when this page appears to be an exception
Default Ignore
Errorpage= "Error/error.jsp"

IsThreadSafe
Used to set whether a JSP file can be used more than a thread. If set to true, a JSP can handle requests from multiple users at the same time, and instead only one user.
True
Istreadsage= "true"

Contenttpye
Defines the MIME type of the JSP character encoding and page response.
Type=text/html

Charset=iso8859-1
Contecttype= "text/html; charset=gb2312 "

Pageencoding
Character encoding for JSP pages
pageencoding=

"Iso-8859-1"
Pageencoding= "gb2312"

Iselignored
Whether the El (expression language) is ignored, and if true, the container ignores the calculation of the "${}" expression
The default value is determined by the version of the Web.xml description file, and Servlet2.3 previous versions will ignore
Iselignored= "true"




B. Include directives

n is used to insert a file that contains text or code, and the inclusion process is static.

N format: <%@ include file= "filename"%>

C. taglib directives

n This instruction allows the page user to customize the label. The content is not clear, put it behind the study

D. Expression language

n JSP2.0 new technology, can simplify JSP development, use "${}" to express

N ${sessionscipe.test} is equivalent to Session.getattribute ("test")

The specific content is not clear, put in the back study



5. Action elements
Action elements work during the request processing phase. When the container handles the JSP, every time it encounters this action element, it is specially handled according to his tag.
Common action Elements

A. <jsp:param>

n is used to provide additional information for other labels.

N Use method: <jsp:param name= "paramname" value= "Paramvalue"/>

B. <jsp:include>

n allows static or dynamic resources to be included in ready-made JSP pages within the requested time. The included object only has access to the JspWriter object, and cannot set headers or cookies. If the page output is buffered, then the buffer is refreshed better than the included refresh.

N Format:

<jsp:include page= "FileName" flush= "true"/> (here flush can only use true)



<jsp:include page= "FileName" flush= "true" >
<jsp:param name= "paramname" value= "Paramvalue"/>

</jsp:include>

C. <jsp:forward>

n allows forwarding of requests to a different JSP, servlet, or static resource file.

N Format

<jsp:forword page= "uri"/> (page is a value or a string that directs a file or URL)



<jsp:forword page= "uri" >

<jsp:param name= "paramname" value= "Paramvalue"/>

</jsp:forword>

D. <jsp:setProperty>

n <jsp:setProperty> works with Usebean to set Bena simple properties and indexed properties.

n <jsp:setproperty name= "Beanname" propertydetails/>

N There are four different ways of Propertydatails:

1. property= "*"

2. Property= "PropertyName" Param=parameteraname

3. Property= "PropertyName"

4. Property= "PropertyName" Value=propertyvalue
Note: You cannot use both Param and value in a <jsp:setProperty>.

E. <jsp:getPorperty>

N complements <jsp:setProperty> operations to access the properties of a bean. The property value it accesses converts it to a string, which is then sent to the output stream. If the property is an object, the ToString () method is invoked.

N Use Method:

1. <jsp:getproperty name= "Beanname" property= "PropertyName"/>

eg

<jsp:usebean id= "Usersession" scope= "session" class= "Com.user.UserSession" >

<jsp:getproperty name= "usersession" property= "name"/>

<jsp:getporperty name= "usersession" property= "password"/>

N Limit: Cannot use <jsp:getPropety> to check a property that has already been indexed. This place doesn't understand.

F. <jsp:useBean>

n is used to create a bean instance in the JSP page and specify his name and scope.

N Syntax:

<jsp:usebean id= "id" scope= "page|requestsession|application" typespec/>

n TypeSpec can use the following four kinds:

1. Class= "ClassName"

2. class= "ClassName" type= "TypeName"

3. Beanname= "Beanname" type= "TypeName"

4. Type= "TypeName"

G. <jsp:plugin> Supplements later

H. Supplements after <jsp:fallback>



Related Article

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.