20180413

1. What are the nine objects, seven actions, and three commands of Jsp?

1. Three Commands:

1. page: This command is a command for the current page.

2, include: used to specify how to include another page.

3, tablib: used to define and access custom labels.

2. Seven major actions:

1. Forward: Perform page forwarding and forward the processing of the request to the next page.

2. param: used to pass parameters, must be used together with other tags that support parameters.

3, include: used to dynamically introduce a JSP page.

4. plugin: used to download JavaBean or Applet to the client for execution.

5、useBean: 使用 JavaBean。

6. setProperty: Modify the property value of the JavaBean instance.

7. getProperty: Get the property value of the JavaBean instance.

Three, nine objects:

1、application:

 An instance of javax.servlet.ServletContext, which represents the Web application to which the JSP belongs, and can be used for JSP pages or for exchanging information between servlets.

 Commonly used methods are getAttribute(String attNarne), setAttribute(String attNarne, String attValue) and getInitPararneter(String paramNarne).

2、config: 

 An instance of javax.servlet.ServletConfig that represents the configuration information for this JSP. Commonly used methods include getInitPararneter(StringparamNarne) and getInitPararneternarnes(). In fact, JSP pages usually do not need to be configured, so there is no configuration information. Therefore, the object is more available in servlets.

3、exception:

 An instance of java.lang.Throwable that represents exceptions and errors in other pages. This object can only be used when the page is an error handling page, that is, when the isErrorPage property of the pragma page is true.

Commonly used methods are getMessageO and printStackTraceO.

4、out:

 An instance of javax.servlet.jsp.JspWriter, which represents the output stream of a JSP page and is used to output content to form an HTML page.

5、page: 

 Represents the page itself, which is usually not very useful. That is, this in the Servlet, and its type is the generated Serlet.

6、pageContext:

 An instance of javax.servlet.jsp.PageContext, which represents the JSP page context and is used to access shared data in the page.

Commonly used methods are getServletContextO and getServletConfigO.

7、request:

 An instance of javax.servlet.http:HttpServletRequest, this object encapsulates a request, and the client's request parameters are encapsulated in this object. This is a commonly used object that must be used to get client request parameters. Encapsulate request attributes, encapsulate address bar parameters, and encapsulate form field values.

 常用的方法有getPararneter(StringparamNarne), getPararneterValues(String paramName), setAttribute(String atttibuteName,Object attributeValue),getAttribute(String attributeName)和 setCharacterEncoding(Stringenv)等。

8、response:

 An instance of javax.servlet.http.HttpServletResponse that represents the server's response to the client. Usually, this object is rarely used for direct response, the out object is used for output response, and the response object is often used for redirection.

 常用的方法有sendRedirect(java.lang.Stringlocation)等。

9、session:

 javax.servlet.http.HttpSession的实例,该对象代表一次会话。从客户端浏览器与站点建立连接起,开始会话,直到关闭浏览器时结束会话。

常用的方法有:getAttribute(StringattName),setAttribute(StringattName,String attValue)等。

2.JSP请求转发与重定向特点以及它们的区别。

重定向:

   response.sendRedirect("地址");
        a. 页面地址显示最终页面
        b. 不可向后传递参数
        c. 跳到外部站点

服务器转发:
   request.getRequestDispatcher("地址").forward(request, response);
        a. 页面地址显示请求页面
        b. 可以向后传递参数
        c. 不可以跳到外部站点

3.请解释mysql语句。

SELECT
 name,password 
INTO
 PersonTable1 FROM PersonTable2 
WHERE
city=”北京”
从表PersonTable2中查询条件为city="北京"的name、password。

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326976380&siteId=291194637