jsp--Learning article: The composition of JSP files

Source: Internet
Author: User

JSP page file consists of JSP elements and template data!

The following is a simple JSP file program code:

1 <%@ Page Language="Java"ContentType="text/html;2 CharSet=UTF-8"3 pageencoding="UTF-8"%>4 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd ">5 <HTML>6 <Head>7 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">8 <title>My first JSP program</title>9 </Head>Ten <Body> One     <!--HTML Comments (display): Seemingly in the source of the Web page can see me - A     <%--jsp Comments (implicit): Hee, in the Web source code you can not see my--%> - all are comments, will not see!!!  -     <HRColor= "Red"> the     <%--This is a Java program segment that represents the declaration of a global variable--%> -     <%!intI= 2; -     //declaration of a method -     intsum (intA,intb) { + return a+b; -     }%> +     <% A         //This is also a Java program segment that represents a declaration of a local variable or method at         intJ= 3; -     %> -  -     <!--This is called the JSP expression statement, can be directly out of the book I+j and - Note the equals sign must be adjacent to%, and no semicolon is required after the statement ends - -     <%=I+J%> in     <BR> -     <!--below we use Java program segment output - to     <% + J=sum (i,j); - Out.print ("I calculated it by expression:"); the Out.print (j);%> * </Body> $ </HTML>
a simple JSP program

This is the run result diagram and view the source map:

Through the above description, we will analyze a basic JSP file composition!

The beginning is the page directive (JSP Element), annotation annotation, declaration, the output of the data! It contains HTML tags, java program code, JSP instruction elements (page instructions) These parts! Because JavaScript can be nested in HTML, JSP files can also contain script fragment files! This is only the JSP element we have not mentioned in the previous, but also we need to learn the knowledge, the next chapter we will focus on the explanation!

By analyzing the above procedures, we should learn how to use annotations, declare variables and methods, and how to use them when mixing labels together!

  

jsp--Learning article: The composition of JSP files

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.