Home > Java > javaTutorial > what language is used in jsp

what language is used in jsp

(*-*)浩
Release: 2019-05-24 14:31:42
Original
6717 people have browsed it

A JSP page can be divided into the following parts: static data, such as HTML, css, js, JSP instructions, such as include instructions, JSP script elements and variables, JSP actions, user-defined tags, static data, etc.

what language is used in jspThe content of the static data in the input file is exactly the same as the content output to the HTTP response. At this time, the JSP input file will be an HTML page without embedded JAVA or actions. Moreover, the client will get the same response content every time it requests.
JSP directive
The JSP directive controls how the JSP compiler generates servlets. The following are the available directives: Include directive include – The include directive tells the JSP compiler to completely include another file into the current file. middle. The effect is as if the contents of the included file are pasted directly into the current file. This functionality is very similar to that provided by the C preprocessor. The extension of the included file is generally jspf (JSPFragment, JSP fragment): <%@ include file=somefile.jsp %>

Page command page – The page command has the following options:

import causes a JAVA import statement to be inserted into the final page file.

contentType specifies the type of generated content.

Use when generating non-HTML content or when the current character set character set is not the default character set. errorPage When processing HTTP requests, if an exception occurs, the error message page will be displayed.

isErrorPage If set to TRUE, it means that the current file is an error page.

isThreadSafe indicates whether the final generated servlet is thread safe (threadsafe).

Note: Only the import page directive can be used multiple times in the same JSP file. Tag library directive taglib – The tag library directive describes the JSP tag library to be used. This directive needs to specify a prefix (similar to the C namespace) and the description URI of the tag library: <%@ taglib prefix=myprefix uri=taglib/mytag.tld %>

JSP Script
Standard script variables
The following are script variables that are always available:

out – the data used by JSPWriter to write to the response stream

page – servlet itself

pageContext – A PageContext instance contains data associated with the entire page. A given HTML page can be passed between multiple JSPs.

request – HTTP request object

response – HTTP response object

session – an object used to maintain the connection between the client and the server Script element
There are three basic scripts Element, its function is to enable JAVA code to be directly inserted into the servlet. One is to declare the tag and put the definition of a variable in the class body of JAVA SERVLET.

Static data members can also be defined in this way. <%! int serverInstanceVariable = 1; %> One is a script tag, which puts the included statement in the _jspService() method of the JAVA SERVLET class.

<% int localStackBasedVariable = 1; out.println(localStackBasedVariable); %> One is the expression tag, which puts the expression to be assigned in the JAVA SERVLET class. Note that the expression cannot start with End with semicolon. <%= expanded inline data 1 %>

JSP Action
JSP action is a series of XML tags that can call functions built into the web server. JSP provides the following actions: jsp:include Similar to the sub-process, JAVA SERVLET temporarily takes over the requests and responses to other specified JSP pages. When the JSP page is processed, control is immediately returned to the current JSP page. This way JSP code can be shared among multiple JSP pages without duplication.

jsp:param can be used between jsp:include, jsp:forward or jsp:params blocks. Specifies a parameter that will be added to the current parameter group of the request.

jsp:forward is used to handle requests and responses to another JSP or SERVLET. Control is never returned to the current JSP page.

jsp:plugin Older versions of Netscape Navigator and Internet Explorer use different tags to embed an applet. This action generates the specified browser tag required to embed an APPLET.

jsp:fallback The content that will be displayed if the browser does not support APPLETS. jsp:getProperty Gets a property value from the specified JavaBean. jsp:setProperty sets a property value in the specified JavaBean.

jsp:useBean Create or reuse a JavaBean variable to the JSP page.

JSP technology can be easily integrated into a variety of application architectures to leverage existing tools and techniques, and can be expanded to support enterprise-level distributed applications. As part of the Java technology family and an integral part of Java 2 (Enterprise Edition Architecture), JSP technology can support highly complex Web-based applications. Because the built-in scripting language of JSP pages is based on Java, and all JSP pages are compiled into Java Servlets, JSP pages have all the benefits of Java technology, including robust storage management and security. As part of the Java platform, JSP has the "write once, run anywhere" feature of the Java programming language.

The above is the detailed content of what language is used in jsp. 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