JSP and EL & JSTL expression

JSP:
  1. concept:
    the Java Server Pages and the: java server pages
    can be understood as: a special page, which can either specify the definition of html tags, they can be defined java code
    to simplify the writing! ! !

  2. Principle
    JSP is essentially a Servlet

  3. JSP script: JSP define how Java code
    1. <Code%%>: java codes defined in the service process. What service method can be defined, what the script can be defined.
    2. <! Code%%>: java code is defined, the position of the members jsp java class after conversion.
    3. <% = Code%>: java code is defined, is output to the page. What output statement can be defined, what the script can be defined.

  4. JSP built-in objects:
    do not need to get in the jsp page and created objects can be used directly, jsp a total of nine built-in objects.

variable name Real type effect
pageContext PageContext Current page to share data, you can also get other eight built-in objects
request HttpServletRequest A request for access to multiple resources (forward)
session HttpSession Requests a session among a plurality of
application ServletContext Among all users to share data
response HttpServletResponse Response Object
page Object Current page (Servlet) this object
out JspWriter Character output stream object. You can output the data on the page. And response.getWriter () similar
response.getWriter () and out.write () the difference:
  before the real tomcat server responds to the client, will go first response data buffer, the buffer data to find out.
  That response.getWriter () output data always out.write () before
config ServletConfig Servlet configuration object
exception Throwable Exception object

 

  5. instruction
    role: to configure JSP page, the resource file import
    format:
      <% @ directive name attribute name attribute value = 1 1 = Attribute Name Attribute Value 2 2 ...%>
    Category:
      1. Page: JSP page configuration
        contentType: equivalent to response.setContentType ()
        Import: guide package
        errorPage: exception occurs after the current page will automatically jump to a specific error page
        isErrorPage: identifies whether the current page is an error page.
          true: yes, you can use the built-in object Exception
          false: no. Defaults. Can not use the built-in object exception

      2. include: the page contains. Import page resource file
        <% @ the include File = "top.jsp"%>
      3. taglib: Import Resources
        <% @ taglib prefix = "c " uri = "http://java.sun.com/jsp/jstl/ Core "%>
        prefix: prefix customized
  6. Notes:
    1. html Note:
      ! <- ->: html code fragment only comment, and the comment is sent to the browser, but not visible on the page
    2. jsp Notes: recommended use
      <% - -%>: You can annotate all

Guess you like

Origin www.cnblogs.com/roadlandscape/p/12207406.html