Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Difference between Include Directive and Include Action tag in JSP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 457
    Comment on it

    Hello reader's lets know the "Difference between include directive and include action tag in JSP(Java Server Page)".

    Include directive and include action tag both are widely-used for including a file to the present JSP page. However you will find there's a difference in how they include file. Lets have an example for better understanding.

    view.jsp

    <html>
    <body>
    <p>This is view.jsp file</p>
    </body>
    </html>
    

    1: JSP Include Directive

    index.jsp

    <html>
    <head>
    <title>JSP include view.jsp Directive </title>
    </head>
    <body>
    <%@ include file="view.jsp" %>
    </body>
    </html>
    

    Output This is view.jsp file

    2: JSP Include Action tag

    index.jsp

    <html>
    <head>
    <title>JSP include view.jsp Action</title>
    </head>
    <body>
    <jsp:include page="view.jsp" />
    </body>
    </html>
    

    Output This is view.jsp file


    You can see the above output for both is identical, however there are usually few noticeable differences included in this:-

    1) Consist of directive includes your file at translation time (the phase of JSP life cycle the place that the JSP gets become the equivalent servlet) whereas the include action includes the report at runtime.

    2) If your included file is changed but not the JSP that's including it then the changes will reflect only once we include things like action tag. The changes will not likely reflect, if you utilize include directive because JSP is not necessarily changed so you won't be translated (during this kind of phase only the file gets included when working with directive) for request processing and hence the changes will not likely reflect.

    3) Syntax difference: Include directive: <%@ include file="fileName" %> in contrast to include action has like this .

    4) When you use include action tag we could also pass the parameters towards included page by utilizing param action tag but in case of include directive its impossible.

    <jsp:include page="fileName" />
    <jsp:param name="parameterName" value="parameterName" />
    </jsp:include>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: