JSP6 (JSP instruction and JSP action Element)

Source: Internet
Author: User

A. JSP directives are used to set the entire JSP page related properties

Directives can have many properties, which exist as key-value pairs and are separated by commas.

Three types of directive tags in JSPs:

page directive

The page directive provides the container with instructions for using the current page. A JSP page can contain multiple page directives.

Syntax format for page directives:

<%@ page attribute= "value"%>
Properties

The following table lists the properties that are related to page directives:

For example:

<%@ Page Language="Java"Import="java.util.*"pageencoding="UTF-8"ErrorPage="showerror.jsp"%><%@ Page Language="Java"Import="java.util.*"pageencoding="UTF-8"Iserrorpage="true"%>

Settings for buffers

 <%@ Page Language="Java"pageencoding="gb2312"AutoFlush="true"Buffer="8kb" %>

include Directives

JSPs can include other files through the include directive. The included file can be a JSP file, an HTML file, or a text file. The contained file is as if it were part of the JSP file and will be compiled at the same time.

<% @ include file = " file relative URL address " %>

two. JSP action Elements

JSP actions can dynamically insert files, reuse JavaBean components, redirect users to additional pages, and so on.

<attribute= "value"/>

Several commonly used are as follows:

< Jsp:include ></ Jsp:include > <  page= "include1.jsp"></jsp:include> tag Dynamic loading, can be with parameters or without parameters

Pass Value:

<page= "include2.jsp"><Jsp:param    Name= "username"  value= "PKD"/></JSP: Include>

Value:

<%      out.println (request.getparameter ("username"));     %>

<jsp:forward></jsp:forward>

<page= "index.jsp"></jsp:forward> tags jump directly to a page, with parameters, or without parameters

Pass Value:

<%   int Age= About; %>      <Jsp:forwardpage= "forword1.jsp">    <Jsp:paramvalue= "<%=age%>"name= "Age"/>    <Jsp:paramname= "User"value= "PKD"/>    </Jsp:forward>

Value:

<%=Request.getparameter (" Age") %><BR/>    <%=Request.getparameter ("User") %>

JSP in Javabean Use

Define assignment:

<Jsp:usebeanID= "Students"class= "PCTC." Studentsbean ">   <Jsp:setpropertyname= "Students" Property= "FirstName"/>   <Jsp:setpropertyname= "Students" Property= "LastName"/>   <Jsp:setpropertyname= "Students" Property= "Age"/>   </Jsp:usebean>

Attribute value:

<name= "Students"  Property= "FirstName"/>  <name= "Students"  Property= "LastName"/> <  name= ' Students '  Property= ' age '/>

Method:

<% =  %>

Job: Show the records in the database in the page, according to the age of the teacher 30 and salary >3000, with the javabean tag to achieve

JSP6 (JSP instruction and JSP action Element)

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.