What is the difference between @include in JSP and Jsp:include

Source: Internet
Author: User

1 Preface

People who do Java development may know that there are two ways to introduce other files in a project in a JSP

<% @include file= "xxx.jsp"%>

<jsp:include page= "xxx.jsp" ></jsp:include>

We may use both approaches, but perhaps many people do not name the difference between the two ways. Let's take a look at the following two examples
2 straight to the question

(1)/include/include.jsp

<%@ page language= "java"  pageencoding= "UTF-8"%>
<%
String path = Request.getcontextpath ();
%>
<p>include Page </p>

(2)/index1.jsp page

<%@ page language= "java" pageencoding= "UTF-8"%>
<%
String path = Request.getcontextpath ();
%>
<! DOCTYPE html>

(3)/index2.jsp

<%@ page language= "java" pageencoding= "UTF-8"%>
<%
String path = Request.getcontextpath ();
%>
<! DOCTYPE html>

Now we have access to index1.jsp and the results are as follows

Then we continue to visit index2.jsp, and the results are as follows

Why, how index1.jsp why visit the error, ah, it seems @include and Jsp:include is a difference. Only by understanding the bottom difference between @include and jsp:include, we know why the index1.jsp page is wrong. Please keep looking and you will understand.

This column more highlights: http://www.bianceng.cn/webkf/JSP/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.