Java-servlet-EL expressions and java labels,

Source: Internet
Author: User

Java-servlet-EL expressions and java labels,

1. Servlet thread security issues

1st. Why does servlet have thread security problems?

2nd. How can this problem be solved?

 

2. Jsp Basics

What is 1st. Jsp?
Essentially a servlet

2nd. How to Write jsp?

I) <%>

II) <% = %>

III) Jsp Declaration (a1.jsp)
<&! Variables or methods &>
After declaration, you can directly use it in code snippets.

I) what is an instruction?
Tell the container to execute some configurations

II) Page command

I. Import attribute: Import package

Ii. Pageencoding attribute: Set the sequence set

Iii. Contenttype attribute: Set the sequence set of the output attribute.

Iv. Session attribute: true (default)/false when the value is false, the session implicit object cannot be directly used. (a2.jsp)

V. Errorpage attribute: Specifies an exception handling page. When an exception occurs, the container calls the exception handling page (a3.jsp)

Vi. Iserrorpage attribute: true/false (default) when the value is true, it indicates this is an exception handling page. exeception implicit object can be used. (a4.jsp)

III) Incloud commands

I. File attributes: included files

IV) Taglib command

I. Used to import jsp labels.

I) what is an implicit object... Objects that can be directly used

II) Why can I use it directly?

III) hidden objects
Out, request, response, session, application,
Exeception, exception handling object, which can only be used on the exception handling Interface
Pagecontext (a6.jsp a7.jsp)

A) uniqueness: the jsp instance corresponds to a pagecontext

B) Persistence: as long as the jsp instance exists, pagecontext will be in (not destroyed)

A) bind data Note: Only the corresponding jsp can access the data bound to pagecontext.

B) obtain all other hidden objects.

Config (a5.jsp) servletconfig (jsp can also set configuration information and obtain it)
Page (never used) jsp instance. Note: jsp is first converted to servlet, and then the container instantiates this servlet.

I) <! -Annotation content --> the z annotation content is executed by the java code, but the time is not displayed on the interface because the html annotation is used outside.

II) <% -- Comment content -- %> the comment content is that java code will not be executed, and neither java code nor java code will be executed in this comment.

 

3. How is Jsp executed?

A) Convert jsp into a servlet class
Html à service method, Output Using out
<%> À copy
<% = %> À out output
<&! Variable or method &> Add a new property or Method

B) Call servlet

4. Jsp tag and El expression

1st. What is a jsp tag?
Jsp tags are similar to html tags and are used to replace java code in jsp.
Note: It is inconvenient to maintain jsp files because java code is directly written in jsp. For example, it is inconvenient to submit jsp files to the artist for modification. Therefore, sun has developed a jsp tag Technical Specification.

2nd. What is an el expression?
It is a set of simple operation rules used to assign values to attributes of jsp tags. It can also be used directly without tags.

Basic use of 3rd. El expressions

I) $ {user. the name} container searches for objects bound to a user from pagecontext, request, session, and application in sequence. next we will call the gername method of this object and output the result of this method.
Note: If the corresponding object cannot be found, "" will be output "".
Converts null to "" output.
You can use pagination, requestScope, sessionScope, and applicationScope to specify the search range.

II) $ {user ['name']}
Note:

  • Read Request Parameter Value (e3.jsp)
  • 4th. Jsp tag jstl (javastandard tag lib) à java standard tag Library

  • Several core labels
  • I) If tag

    I. <c: iftest = "">
    <C: if>
    When the value of test is true, the container executes the content of the label body. You can use the el expression to assign values to test,
    Var attribute: specify a binding name.
    Scope attribute: Specify the binding range. page request session application

    Ii. Choose tag (c2.jsp)
    <C: choose>
    <C: when test = "">
    <C: otherwise>
    <C: otherwise>
    </C: choose>
    When can appear 1 time otherwise can appear 0 to 1 time

    Iii. ForEach tag (c3.jsp)
    <C: forEach items = "var =" varStatus = "> </c: forEach>

     

    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.