JSP Learning Notes _JSP programming

Source: Internet
Author: User
1. When declaring variables: <%! int j=1;%> (converts a variable to a member variable of a servlet class, where multiple clients share one) and the <% int j=1;%> (just a local variable within a method, one for each client) is used in the process of Try to avoid declaring a variable as a member of a class unless you want to count the number of times a servlet class has been accessed. The latter cannot define a method, the former can.

A 2.java script (such as JavaScript) executes on the server side of the,<%......%> of the client and then returns the results back to the client.

3.JSP contains instructions:
static inclusions (Common): <%@ include file= "FileURL"%> copy the contained files to that location, compile, convert, but only one Java and class file, FileURL cannot contain parameters, The containing page and the included page are accessed by the same request object, which is equivalent to a page and must be encoded in the same way;
Dynamic inclusion (not common): <jsp:include page= "FileURL" flush= "true"/>fileurl is a parameter that can be passed, and is different from the object that contains the page request But you can take the same parameters (small can request to large parameters, you can add your own parameters), when needed to convert, compile, in the background generated two Java and class files.

4. Two ways to jump:

Response.sendredirect ("FileURL"); In the course of the jump, the address bar will change, after the jump into the address of the page after the jump, the server to the client two round-trip, inefficient, slow (client request-server response, turn to the client, The client Address bar changes (address can be any legal address such as other URLs), autocommit, request a new address to the server-the server found the results of the feedback to the client to display; The page that you go to cannot go to the previous page parameter; "/" in the URL represents the root path to the domain name

<jsp:forward page= "FileURL"/> client requests, the server side directly to the new address and then the results to the client, the process of the address bar does not change, the server to complete the conversion (the address can not be transferred to the address); fast , although it is a different object, it can be taken to the parameters of the previous page; Forward subsequent statements will not continue; the "/" in the URL represents the root path to the WebApp project

5.JSP Label Scope scope has page, request, session, application from small to senior, by default is page
The 6.math.floor (cost*100)/100.0 cost is a double type, and the Math.floor (cost*100) function is used to return the integer portion of the cost*100
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.