JSP overview of the Introduction to JSP Beginner Tutorial

Source: Internet
Author: User
Tags define expression include variables relative
The js| tutorial (IAVA SERVER pages) is a dynamic Web page production technology developed by Sun in the Java language that allows you to separate the dynamic parts of a Web page from the static HTML. You can use tools that are usually handy and write HTML statements in the usual way. The dynamic parts are then embedded with special tags, which often start with "<%" and End With "%>". For example, here is a JSP page:


Tutorials</title>
<body>

<I> <%out.println ("Hello World");%> </I>

</body>
It will output "Hello World".

Typically, you want to extend the file to ". JSP" and place it under any path that you can place on a normal web page. Although the JSP file looks more like an HTML file than a servlet file, it is actually converted to a servlet file, where static HTML is used only to output information returned by the Servlet service method. If the JSP pages have been converted to a servlet and the servlet is compiled and then loaded (when asked for the first time), when you request this JSP page again, you will not notice a delay. Also note this phenomenon, some Web servers allow you to define aliases for it, as if a URL is pointing to an HTML, but in fact it points to a servlet or JSP pages.

Constructs a JSP page, in addition to the embedded rules of HTML, there are three main types of JSP elements: Scripting elements,directives, and Actions. Using scripting Elements you can define the part that is eventually converted to a servlet, directives allows you to control the overall structure of the servlet, and the actions allow you to specify reusable components that can be reused, as well as control the running of the JSP engine. To simplify scripting elements, you can use some predefined variables, such as request, on a section.

This tutorial is explained in the JSP1.1 version. Its syntax is summarized in the following table, and its detailed use is explained in detail in subsequent courses.

JSP elements Grammar Explain
JSP Expression <%= expression%> Expression is used for calculation and for output.
expression , the predefined variables you can use are request, response, out, session, Application, config, and PageContext (can also be used in sriptlets).
JSP Scriptlet <% Code%>
Inserts code for the service.
Code
JSP Declaration Code that belongs to the servlet section but is not a service method.
Code
JSP page directive <%@ page att= "Val"%> Point to the path to the servlet engine.
. The following are its legitimate properties (the default is bold):

Import= "Package.class"
Contenttype= "Mime-type"
Isthreadsafe= " true|false"
Session= " true|false"
Buffer= "Sizekb|none"
Autoflush= " true|false"
Extends= "Package.class"
info= "Message"
errorpage= "url"
Iserrorpage= "true| false"
Language= "Java"
JSP include directive <%@ include file = "URL"%> A file on the local system that will be included when the JSP page is translated into a servlet.
this URL must be relative. "Jsp:include action" is used when the page is requested.
JSP comments <%--annotation--%> When the JSP is converted to a servlet, it is ignored.
<--annotation-->
The Jsp:include Action The page is requested (requested) Si Cho into the file.
If you want the file to be included when the page is converted (translated), use the directive mentioned above instead. Warning: On some servers (Servers), the included files can only be HTML or JSP, usually judged by the suffix name of the file.
The Jsp:usebean Action or
.....
Look for or generate a Java Bean.
The possible properties are:

Id= "Name"
Scope= "page|request|session|application"
Class= "Package.class"
Type= "Package.class"
Beanname= "Package.class"
The Jsp:setproperty Action Set the properties of the bean by explicitly specifying or using the parameters obtained by the request.
Valid properties:

Name= "Beanname"
Property= "propertyname|*"
Param= "ParameterName"
Value= "Val"
The Jsp:getproperty Action Retrieves and outputs the properties of the bean.
The Jsp:forward Action
Forward requests (Request) another page.
The Jsp:plugin Action
Generates an object or embed label for a specific browser to explicitly run the Java plug-in (plugin) used by the applet.


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.