[Application] The second JSP comes with tag introduction

Source: Internet
Author: User

JSP has the following three categories of tags: directive: JSP Directive

Directive tags are used to set properties related to the entire JSP page.
The following three tags are the most frequently used

label JSP Tags Description
<%@ page ...%> use comparison <jsp:directive.page attribute= "Value"/> Define dependency properties on a page, such as 脚本语言、页面编码、缓存需求
<%@ include:%> static inclusions, using more <jsp:directive.include file= "Relative url"/> Introduce other files, such as JSP, HTML, text files,先包含后运行
<%@ taglib ...%> reference label <jsp:directive.taglib uri= "uri" prefix= "Prefixoftag"/> Introduction of Tag library, can be JSP standard tag library (JSTL), can also be custom tag library
Script:JSP Syntax[Not recommended!]
The
!--more-->

Syntax tag was earlier in Java designed to make it easier for developers to write business logic in JSP pages, but is no longer recommended.

label jsp label
<% scriptlet%> <JSP:SCRI Ptlet> scriptlet </jsp:scriptlet> script program that can contain any valid Java statement, variable, method, or expression
<%! declaration%> <jsp:declaration> Decl Aration </jsp:declaration> No, I don't know how to do this! Declaration statement, you can declare one or more variables, methods, for subsequent Java code to use
<%= expression%> <jsp:expression> Express Ion </jsp:expression>
<%–COMMENT–%> No, code comment, the page source does not display

Code Description:

  1. <body>
  2. <%!String output ="world"; %>
  3. <%out.println("Hello "+ output); %>
  4. <br/>
  5. <%="Hello "+ output %>
  6. </body>

Good low code, although the combination of these three syntax tags, you can write a large segment of Java logic code in the JSP page, but it is strongly not recommended, because this will lead to the front page and business logic tightly coupled, so 后续难以维护 .

Action: JSP Action semi-retired state

function tags are predefined, well-defined behavior tags that are used occasionally.

label Description
<jsp:include> Used to include static or dynamic resources in the current page.先运行后包含
<jsp:forward> Passing a JSP file from one file to another contains a 用户请求的 request 对象请求转发
<jsp:useBean> Just not recommended to use, did not say abandoned! Find and initialize a JavaBean component
<jsp:getProperty> Inserting the value of the JavaBean component into output
<jsp:plugin> Used to include applets and JavaBean objects in the generated HTML page.个人用过一次,挺好玩的Applet,当年感觉很神奇
<jsp:element> Dynamically creating an XML element
<jsp:forward> Passing a JSP file from one file to another contains a 用户请求的 request 对象请求转发
<jsp:attribute> Defining properties for dynamically created XML elements
<jsp:body> Defining the body of dynamically created XML elements
<jsp:text> Used to encapsulate template data,有空看看,也许好玩呢!虽然我已经开始使用各种模版引擎了!


From for notes (Wiz)

[Application] The second JSP comes with tag introduction

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.