Java Knowledge Summary-6

Source: Internet
Author: User
Tags tag name

JSP Knowledge points
Tags: Java server Page

Basic Features

Declaration statement

Expression expressions

Directives directive

Scriptlet Small Program Segment

Comment Notes

Action Actions Command

! Run as a. java file before conversion to a servlet compiled file run (. Class)

1. Only the client needs to convert the JSP for the first time when it is requested to compile

Advantages

Excellent performance (for CGI PHP ASP)

Platform agnostic (can be run on the platform as long as it complies with the Java EE specification)

Strong scalability (TGA expansion, simplified development)

Supplemental knowledge

There must be no parameter constructor in the class of reflection, otherwise it is easy to error

Operation section

Directive <%@%>

Include directives

FILE = "path"

The import file command includes the specified JSP program or HTML file in the current page

<%@ include file = "/a.jsp"%>

You can import another JSP file to the public part of a Web page such as the head of a Web site

Page directive

Import = Package and class introduced by "package name. Class Name"

You can import multiple packages by separating the middle with commas

extends = "Package name. Class Name" inherited class

buffer= "none/kb size" does not buffer or specify buffer size (default 8KB)

Autoflush= "True/false" automatically clears the buffer

info = description information for "description" JSP file

Iserrorpage= "True/false" The current page has an error

errorpage= "url" If the page is wrong, the page displayed

Contenttype= Property information for the "Contentypeinfo" page

<% @page session= "true"%> (default)--indicates that the session function has been started in the JSP page

pageencoding= "gb23123" setting encoding format

TAGLIB directive

Import Directives tab

<%@ taglib prefix= "C" uri= "select"%>

"C" is an alias (the JSP directive is used when the tag name) "Select" is generated by the shortcut key is generally http://java.sun.com/jsp/jstl/core the tag library as a standard tag library can realize the operation of the judgment loop

You can use Taglib tags to import JSP other tags to achieve some special functions

<c:if test= "" var= "" scope= "" > tag body
When the </c:if> test property value is true, the contents of the tag body (which can be Html,java code) are executed.
Test property: Use an El expression to assign a value.
var attribute: Specify a binding name
Scope Property: Specifies a binding range (Page,request,session,application).
<c:choose>,<c:when>,<c:otherwise>
When represents a branch, can appear multiple times;
Otherwise represents an exception and can only occur once;
When the test property value is true, the contents of the tag body (which can be Html,java code) are executed.
<c:foreach var= "" items= "" varstatus= "" >
</c:forEach> Traversal Collection Items Property: Specifies the collection to traverse, typically using the
An El expression to specify.
var attribute: Specifies the binding name and binding range is PageContext.
Varstatus Property: Specifies the binding name that corresponds to a special object that encapsulates the state of the current traversal.

Action <jsp: Action Name property = "Value"/>

Forward action

<jsp:forward page= "a.jsp"/>

Jump to another page to transfer the contents of a JSP to the JSP program specified by the page or to the servlet for processing (URL)

Usebean Action

<jsp:usebean id= "BJ" class= "Package name". Class name "/>

Use the JavaBean class ID as an alias

<jsp:setproperty property= "A" name= "B" value= "C"/> Property name of Class B JavaBean name (BJ) C Property value

Set the property value for the JavaBean used

<jsp:getproperty property= "A" name= "BJ" > A property name BJ uses the alias of the JavaBean

Get the JavaBean property value

<jsp:param value= "Apple" name= "key"/> JSP page to use the Name= "key" equivalent to the key value value= "Apple" is a significant value

Include action

<jsp:include page= "A.. JSP "/>

Dynamic combination of two pages

Comments

<!----> the comment client can see it in the source code

<%----%> the comment client is not visible in the source code

Expression <%= Java Properties/Variables%>

Can reference values in Java code

java Script <% Java code%>

Java code can be executed (pre-Java to maintain consistent attention to the guidance package)

Statement <%! Method%>

Theoretical part

The difference between the include of the command and the include (merged page) of the action
Tags: blue

Static Import

1. Use <[email protected] include file= "a.jsp"/> Instructions

2. Copy the contents of page B to page A, then compile it into a Java file, and put it into the work directory when converting to a. class file.

3. Generate File A.java A.class

Dynamic Import

1. Use <jsp:include page= "b.jsp"/> Action

2. Standalone compilation is dynamically combined as a page when accessed by the server

3. Generate file A.java a.class B.java b.class

JSP nine large built-in objects (you can call methods directly)

PageContext specific objects in the JSP (JSP context object, for the current page)

The request object from the servlet is derived from the HttpServletRequest

HttpSession in the session source Servlet

Application Source ServletContext

Response Source HttpServletResponse

PrintWriter in the Out source servlet

The Servlet object that is generated after the page JSP is compiled

Config servletconfig get servlet configuration parameters

Exception exception class for Throwble page

The running process of the label

The process of label operation:
The container finds the label's description file (. tld file) According to the namespace,
Find the Label class based on the name of the label, then create an instance of the label class and execute the corresponding method.


Web Storage status----Reference HTML Supplemental Knowledge Summary

EL expressions (Expression language)

A simple way to remove values from all scopes

Basic syntax ${Value}

${key} represents the search for "key" from four scopes

${sessionscope.key} represents the search for "key" from the session

There are also pagescope Requestscope sessionscope applicationscope

Operators can be operated on such as ${10+2*8}

${user.name} represents the value of name removed from the Java class user

El expression cannot be looped

Cookie Browser Small text information

Server writes cookie information

In a servlet, a cookie object can store only one string of information. Multiple cookies are required if more than one is stored

*response Addcookie method to get Cookie object

--finally send the cookie to the browser, the browser automatically writes to the client location

Cookie Server writes small text information (a map collection of text) to the client, which is used for logging user name password and other information to implement automatic login function information insecure

JSP takes out the value in the cookie

%java Script%>
Cookie[] Cs=request.getcookies () get an array of cookie objects
The Foreach Loop calls the Getname/getvalue method to get the key and value to set the text input box to the value just obtained by default
Tags: the ability to automatically fill out accounts

Java Knowledge Summary-6

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.