<%@include%>和<jsp:inclued />的区别【可追加分数】
<%@include%>可以包含任意页面,处理动态页面时:先包含,再处理;<jsp:include/>处理动态页面时:先处理,在包含-------------------...
<%@include%>可以包含任意页面,处理动态页面时:先包含,再处理;
<jsp:include/>处理动态页面时:先处理,在包含
------------------------------
给个例子。。谢谢。 展开
<jsp:include/>处理动态页面时:先处理,在包含
------------------------------
给个例子。。谢谢。 展开
3个回答
展开全部
<iAndF.jsp>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<title>jsp:include和jsp:forward的区别比较!</title>
</head>
<body>
<form name="form1" method="post" action="loginProcess1.jsp">
用户名:<input type="text" name="id" size="20"><br>
密  码:<input type="password" name="pwd" size="20"><br>
<input type="submit" value="正确登陆示范">
<input type="reset" value="重置">
</form>
<form name="form2" method="post" action="loginProcess2.jsp">
用户名:<input type="text" name="id" size="20"><br>
密  码:<input type="password" name="pwd" size="20"><br>
<input type="submit" value="错误登陆示范">
<input type="reset" value="重置">
</form>
<%@include file="contact.jsp" %>
</body>
</html>
<loginProcess1.jsp>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%
String userId=request.getParameter("id");
System.out.println(userId);
String userPwd=request.getParameter("pwd");
System.out.println(userPwd);
if(userId.equals("ZhangSan")&&userPwd.equals("123"))
{
%>
<jsp:include page="success.jsp"></jsp:include>
<%
}
else
{
%>
<jsp:include page="failure.jsp"></jsp:include>
<%
}
%>
<%@ include file="contact.jsp" %>
<loginProcess2.jsp>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%
String userId=request.getParameter("id");
System.out.println(userId);
String userPwd=request.getParameter("pwd");
System.out.println(userPwd);
if(userId.equals("ZhangSan")&&userPwd.equals("123"))
{
%>
<jsp:forward page="success.jsp"></jsp:forward>
<%
}
else
{
%>
<jsp:forward page="failure.jsp"></jsp:forward>
<%
}
%>
<%@ include file="contact.jsp" %>
<success.jsp>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
登录成功!<br>
<%@ include file="contact.jsp" %>
<failure.jsp>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
登录失败!<br>
<%@ include file="contact.jsp" %>
<contact.jsp>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<title>contact</title>
</head>
<body>
<font color="#FF0000" style="font-size:12px; font-style:italic"> @版权所有:【No.1】个人程序设计</font>
</body>
</html>
shadow的例子很清楚了
<jsp:include page="b.jsp">
good
study
运行结果:
good
good
study
<jsp:forward page="b.jsp">
good
study
运行结果:
good
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<title>jsp:include和jsp:forward的区别比较!</title>
</head>
<body>
<form name="form1" method="post" action="loginProcess1.jsp">
用户名:<input type="text" name="id" size="20"><br>
密  码:<input type="password" name="pwd" size="20"><br>
<input type="submit" value="正确登陆示范">
<input type="reset" value="重置">
</form>
<form name="form2" method="post" action="loginProcess2.jsp">
用户名:<input type="text" name="id" size="20"><br>
密  码:<input type="password" name="pwd" size="20"><br>
<input type="submit" value="错误登陆示范">
<input type="reset" value="重置">
</form>
<%@include file="contact.jsp" %>
</body>
</html>
<loginProcess1.jsp>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%
String userId=request.getParameter("id");
System.out.println(userId);
String userPwd=request.getParameter("pwd");
System.out.println(userPwd);
if(userId.equals("ZhangSan")&&userPwd.equals("123"))
{
%>
<jsp:include page="success.jsp"></jsp:include>
<%
}
else
{
%>
<jsp:include page="failure.jsp"></jsp:include>
<%
}
%>
<%@ include file="contact.jsp" %>
<loginProcess2.jsp>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%
String userId=request.getParameter("id");
System.out.println(userId);
String userPwd=request.getParameter("pwd");
System.out.println(userPwd);
if(userId.equals("ZhangSan")&&userPwd.equals("123"))
{
%>
<jsp:forward page="success.jsp"></jsp:forward>
<%
}
else
{
%>
<jsp:forward page="failure.jsp"></jsp:forward>
<%
}
%>
<%@ include file="contact.jsp" %>
<success.jsp>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
登录成功!<br>
<%@ include file="contact.jsp" %>
<failure.jsp>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
登录失败!<br>
<%@ include file="contact.jsp" %>
<contact.jsp>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<title>contact</title>
</head>
<body>
<font color="#FF0000" style="font-size:12px; font-style:italic"> @版权所有:【No.1】个人程序设计</font>
</body>
</html>
shadow的例子很清楚了
<jsp:include page="b.jsp">
good
study
运行结果:
good
good
study
<jsp:forward page="b.jsp">
good
study
运行结果:
good
展开全部
在jsp里面随便调用一个Servlet。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<%@include %> 是静态包含,可以包含任何内容。
例如在A.jsp中 <%@ include file="a.txt" %> ,先把 a.txt 中的内容原封不动的包含到A.jsp 中,相当于一个生成一个新的jsp 再交给Servlet 容器(Tomcat)编译。
<jsp:include /> 是动态包含,
例如在B.jsp 中<jsp:include path="c.jsp"/> ,Servlet容器将会先 编译c.jsp ,把c.jsp 的结果包含到B.jsp 中,然后再一起编译 B.jsp 。
例如在A.jsp中 <%@ include file="a.txt" %> ,先把 a.txt 中的内容原封不动的包含到A.jsp 中,相当于一个生成一个新的jsp 再交给Servlet 容器(Tomcat)编译。
<jsp:include /> 是动态包含,
例如在B.jsp 中<jsp:include path="c.jsp"/> ,Servlet容器将会先 编译c.jsp ,把c.jsp 的结果包含到B.jsp 中,然后再一起编译 B.jsp 。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询