--JSP review study notes JSP action tags

Original link: http://www.cnblogs.com/fingerboy/p/5173455.html

  Previous notes written instructions jsp nine three built-in objects, this essay began to write jsp action tags, labels action by the server (Tomcat) to explain the implementation, as with java code are executed on the server of, jsp action tags have more than a dozen, just to write a few more commonly used.

  •   <jsp:include> 

    Comprising: RequestDispatcher and include methods is the same, except in a jsp, one used in the servlet

  This tag is generally called dynamic included, because at the time he was at compile time, the current jsp page and jsp include incoming generates two java files, thereby generating two class files, just received a request to merge the results together with the jsp instructions <% @ include%> is very different, which will merge into a Java file compilation stage and a class file.

  •   <jsp:forward>

    Forward: RequestDispatcher and forward method is the same, just in a jsp in use in a servlet, its role is to "Do not show me, show go forward inside pages of it."

  •   <jsp:param>

    Parameter passing: it can be used as two or more sub-label tag, may be used to pass parameters in the two pages to include the tag as an example, a new a.jsp following:

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
  <head>
   
  </head>
  
  <body>
       <h1>a.jsp</h1>
       <jsp:include page="b.jsp">
               <jsp:param name="name" value="张三"/>
               <jsp:param name="age" value="18"/>
        </jsp:include>
  </body>
</html>

To build a b.jsp, retaining only the following code:

    <h1>b.jsp</h1>
    <%
        String  name=request.getParameter("aname");
        String age=request.getParameter("aage");
        out.print(name+"---"+age);
    %>

Such parameters can be acquired, name and age in b.jsp a.jsp passed in.



Reproduced in: https: //www.cnblogs.com/fingerboy/p/5173455.html

Guess you like

Origin blog.csdn.net/weixin_30808253/article/details/94790470