What is JSP?

What is JSP?
A server-side dynamic page technical specification formulated by Sun.
JSP is actually a file suffixed with "jsp". The content of the file is mainly html and a small amount of java code. The container will automatically convert the jsp file into a servlet and execute it.
How to write a JSP file?
Step1, create a file with the suffix ".jsp".
step2, in the file, add the following content:
(1) html (css.js): write directly.
(2) java code
1) java code fragment
                   <% java statement; %>
2) jsp expression
                  <%=java expression%>

(3) Implicit object
1) What is the implicit object
In the jsp file, the object that can be used directly, such as out, request, response.
2) Why is it possible to use these implicit objects directly?
(4) Instruction
1) Notify the container that when converting the jsp file into a servlet class, do some additional processing, such as guiding the package.
2) Instruction syntax
                     <%@ instruction name attribute = attribute value%>
3) page instruction
a.import attribute: import package
such as <%@page import="java.util.*"%>
b.contentType attribute: set
response The content of .setContentType.
c.pageEncoding attribute: Tell the container the encoding of the jsp file
(some containers, when reading the content of the jsp file, the default
is to decode according to ios-8859-1, if
the jsp file contains Chinese, there will be garbled characters).


How is the jsp executed?
step1, the container converts the jsp file into a servlet class.
         html(css,js) -------> In the service method, use out.write to output.
  <% java statement%> -------> In the service method, copy it.
<%=java expression%> -------> In the service method, use out.print(java expression) to output.
step2, the container calls the servlet.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325257253&siteId=291194637