Javaweb Series-jsp Basic syntax

Source: Internet
Author: User
Tags define local

JSP comments (in the page, right-click to see if the source code is visible)

1. Explicit annotations visible to clients

<!--comment Content--

2. Implicit annotations that are not visible to the client

Single-line comment//comment content

Multiline comment/* Comment content */

JSP comment <%--Comment content--%>

Explicit content is sent to the client, and implicit content is not sent to the client


Scriptlet All Java programs that are embedded in HTML code must be marked with the scriptlet.

    1. <%%>

      You can define local variables in markup, write statements

    2. <%!%>

      You can define global variables, methods, and classes in markup. The defined content can be used in <%%>. <%!%> no other content can appear.

    3. <%=%>

      You can output a variable or a specific content in a tag

    4. <jsp:scriptlet>java scriptlet Code </jsp:scriptlet>

      To prevent confusion, it is equivalent to <%%>. It's good to be nice.


Page directive

<% @page property = "Content"%> defines the related properties of a JSP page

Contenttype= "TEXT/HTML;CHARSET=GBK" defines the character encoding, the MIME type of the page response

Iserrorpage can be set to TRUE or False

ErrorPage to the Display page after error, to use with Iserrorpage

Import page Pour the Action pack


PS:MIME specifies what application the browser should use to open the extension file when it is accessed. Setting an error may cause the content that should be displayed to be programmed one now prompt box


Pageencoding refers to the encoding of the JSP file itself, while the CharSet in ContentType refers to the content encoding that the server sends to the client.


Static inclusions

<%@ include file= "file path"%>

JSP inserts a file that contains text or code at compile time


Dynamic inclusion

If the static page static contains the sample processing, if the dynamic page first dynamic processing, and then the processed results are included in the

<jsp:include page= "file path" >

<jsp:param name= "parameter name" value= "parameter contents"/>

</jsp:include>

The passed parameter is used Request.getparmeter ("parameter name") in the contained page;


Jump Instructions

Do not pass parameters

<jsp:forward page= "Jump page"/>

Passing parameters

<jsp:forward page= "Jump page" >

<jsp:param name= "parameter name" value= "parameter contents"/>

</jsp:forward>


Next article: Javaweb series-JDBC

This article is from the "Lincoln" blog, please be sure to keep this source http://president.blog.51cto.com/4990508/1787043

Javaweb Series-jsp Basic syntax

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.