Commonly used tags in JSPs

Source: Internet
Author: User

JSP is essentially a servlet, but Tomcat translates it into Servlet,servlet, which is essentially a class, and JSP is also a class. Various tags in the JSP are translated into basic Java code by Tomcat

If a variable is defined in a JSP page, it can be obtained directly from another location, for example

<%string name = "Zhangsan";%><%= name  %>

But please note that the current development is not in the JSP to write Java code, the above is Java code, now is the need to use the JSP tag. What is a JSP tag? Here's an example

1.$ tag (el tag)

<%pagecontext.setattribute ("name", "Lisi");%>${name}


Output Result: Lisi

In the JSP want to directly with the El ($) tag need to put the variables in four fields, this time can be directly obtained, this is the El tag rules. The Java code above simply places the variables in the domain and is directly accessible. Four fields, namely

page, request, session, application. The page field is only available in this JSP page, and the request domain can be obtained in one call, and if the request is forwarded on the line, redirection cannot be used. Session represents a conversation,

A session is one that opens a browser, and then it is created. Application is the domain placed on the server, as long as the server is open, this domain can be obtained from anywhere.

Commonly used tags in JSPs

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.