日期:2014-05-18  浏览次数:20577 次

jsp中调用servlet
我想在jsp网页中包含某个servlet的执行结果,
也就是让一个servlet的结果作为jsp网页的一部分显示出来,应该怎么写。
请各位帮忙,谢谢大家!

------解决方案--------------------
iframe
------解决方案--------------------
LZ你的逻辑不对哦,根据MVC模式,是将一个请求,经过Servlet处理,然后保存到JavaBean中,
然后将这些beans放在request或session中,然后发送视图到jsp,在jsp中获取此request/session中bean对象,然后读取其数值在显示到jsp哦
------解决方案--------------------
<html>
<head>
<base href= " <%=basePath%> ">

<title> My JSP 'MyJsp1.jsp ' starting page </title>

<meta http-equiv= "pragma " content= "no-cache ">
<meta http-equiv= "cache-control " content= "no-cache ">
<meta http-equiv= "expires " content= "0 ">
<meta http-equiv= "keywords " content= "keyword1,keyword2,keyword3 ">
<meta http-equiv= "description " content= "This is my page ">
<!--
<link rel= "stylesheet " type= "text/css " href= "styles.css ">
-->

</head>

<body>
This is my JSP page. <br>
<jsp:include flush= "true " page= "servlet/MyServlet "> </jsp:include>
</body>
</html>