Home > Java > javaTutorial > What is jsp page

What is jsp page

(*-*)浩
Release: 2020-09-16 16:28:36
Original
8468 people have browsed it

JSP page refers to a page that adds java program and jsp tags to the traditional HTML page file. The extension of a JSP page file is jsp, and the name of the file must comply with the identifier regulations.

What is jsp page

The extension of a JSP page is .jsp or .jspx. The web server uses this extension to notify the JSP engine to process the elements in the page. Other extensions can also be used to contact the JSP engine through the deployment descriptor web.xml.

Recommended courses: java courses

A JSP page file is formed by adding Java programs and JSP tags to the traditional HTML page file. To put it simply, in addition to ordinary HTML tags, a JSP page uses the tag symbols "<%" and "%>" to add Java programs. The extension of a JSP page file is jsp, and the name of the file must comply with the identifier regulations. It should be noted that JSP technology is based on the Java language, and the name is case-sensitive. To clearly distinguish between uppercase and lowercase letters, we write ordinary HTML markup symbols in uppercase letters.

Example:

<%@pagr contentType="text/html;charset="utf-8"%>
<HTML>
	<BODY BGCOLOR=cyan>
		<FONT Size=1>
			<P>
				这是一个简单的JSP页面
				<% int i,sum=0;
					for(int 1;i<100;i++)
					{
						sum=sum+i;
					}%>
			</p>
			<P>
				1到100的连续的和是:
				<BR/>
				<%=sum%>
			</P>
		</FONT>
	</BODY>
</HTML>
Copy after login

The exact format of a JSP page is described in the JSP specification.
Use the JSP engine to interpret the tags in the JSP page and generate the required content. For example, call a bean to access a database using the JDBC API or to include a file. The JSP engine then sends the returned results to the browser in the form of an HTML (or XML) page. Essentially, the business logic of generating content is encapsulated in tags and beans processed on the server side.

JSP pages are usually compiled into Java platform servlet classes. Therefore, the running of JSP pages requires a Java virtual machine that supports the Java platform servlet specification.
The JSP page is actually only compiled once when it is called for the first time. The page is compiled into a Java Servlet class and resides in server memory so that subsequent calls to the page will be fast.

Of course, the JSP specification supports the creation of XML documents. For simple XML document generation, the XML tags will be included in the JSP page as a static part. Dynamic XML generation requires the use of bean components or custom tags. See the white paper Developing XML Solutions with JavaServer Pages Technology (PDF) for more details.

The JSP 2.0 specification describes the mapping between JSP pages and XML documents. This mapping enables you to use XML tools to generate and process JSP pages.
The JSP specification includes standard tags for using and handling beans. Use the useBean tag to generate an instance of a specific JavaBeans. If an instance of this class already exists, it is used directly. Otherwise, create a new instance. The setProperty and getProperty tags allow you to manipulate the properties of a given object.

Related recommendations: java introductory tutorial

The above is the detailed content of What is jsp page. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
jsp
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template