JAVA Note No.2

Source: Internet
Author: User
Tags tld

various elements in 1.JSP: Code snippets, annotations, built-in objects, expressions

(1) code snippet:<%%>

   ( 2 <%--    %> ( html <%//   %> or <%/*    /*%> ( java )

   ( 3 request session , application , config , exception , out , page , pagecontext

(4)JSP expression:<%=%>

(5)JSP definition block:

① Global variables (definition method also used):<%! %>

② Local variables:<%=%>

(6)JSP directive:<% instruction name attribute 1= value 1, ... ..., property n= value n%>

① page directive: Defining global properties for the entire page

<% @page ... %>

②include directives: Files used to contain a text or code

<% @include ... %>

(7) Other

① introduced tag library:<%@ taglib uri="prefix=" "%>

② do not create session:<% @page ... session="false"%>

2.EL(expressionLanguage) expression,EL -to-a-range mechanism

(1) expression

① arithmetic operation:1+2=${1+2}

② relational operations:5>3?${5>3}

③ logical operation:5>3 and 3<2?${5>3 and 3<2}

5>3 or 3<2?${5>3 or 3<2}

Not 5>3?${not (5>3)}

(2) scope mechanism

get a range of data:username:${requestscope.username},username:${sessionscope.username}, Username:${applicationscope.username}

For example,username:${username}, if no range is specified, start looking from the minimum range, i.e. from requestscope . If not, find a wide range (Order:page→request→session→application ) is not found, the blank is displayed.

3.JSP tags (JSP actions)

(1)<jsp:forword page="main.jsp" ></jsp:forword>

(2)<jsp:include page="main.jsp" ></jsp:include>

4. familiar with TLD(Tag Library Descriptionfile, Tag database description) document content

*. The TLD describes how the labels in the tag library are used. the TLD file is located in JSTL 1.2.2 Library/jstl-impl-1.2.2.jar/meta-inf/maven .

as C Tag Library:

JSTL 1.2.2 Library/jstl-impl-1.2.2.jar/meta-inf/maven in the c.tld file.

where the <uri></uri> represents its address.

<short-name>c</short-name> indicates the recommended abbreviation.

<tag></tag> represents a property in a C tag.

5. Learn about the C tag library

JSTL 1.2.2 Library/jstl-impl-1.2.2.jar/meta-inf/maven in the c.tld file.

where the <uri></uri> represents its address.

<c:if test= "..." ></c:if>,<c:when test="..." ></c:when>,<c : Out value="..." ></c:out>,<c:url value="..." ></c:if>,< C:choose></c:choose>,<c:otherwise></c:otherwise>

6. What are the three tiers of the three-tier architecture?

Presentation Layer (presentation layer), Commercial logic layer (businesslayer), data persistence (persistence layer )


(1)response.sendredirect ("load_student.jsp");

(2)<jsp:forword page="load_student.jsp" ></jsp:forword>


(1) can only use <jsp:forword> in this site to jump, and response.sendredirect Can jump to any one of the addresses of the page.

(2)<jsp:forword> jump with the information in request, and Sendredirect no request information to jump.

8. Understanding The servlet life cycle

The servlet life cycle defines how a servlet is loaded, initialized, and how it receives requests, responds to requests, and provides services.

(1)init ()

in the in the servlet's life cycle, the init () method is executed only once, which is performed when the server loads the servlet and can be configured with the server.

(2)service ()

whenever a customer requests a The HttpServlet object, which is called by the Service () method of the object .

(3)destroy ()

execute only once, stop on server side and uninstall Servlet When the method is executed .

JAVA Note No.2

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: 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.