日期:2014-05-17  浏览次数:20609 次

jsp 显示服务端返回的html 文件及图片 问题
采用servlet 和 jsp 包含 html 和 图片 的文件 显示,代码如下:

显示html 文件:

sevlet 代码:

String htmlFilePath = "./file" + htmlName;
request.getSession().setAttribute("htmlFilePath", htmlFilePath );



jsp 代码:

String htmlFilePath= (String)session.getAttribute("htmlFilePath");
<jsp:include page="<%=htmlFilePath %>"></jsp:include>



显示图片 文件:

sevlet 代码:

String imgPath = "./file" + imgName;
request.getSession().setAttribute("imgPath ", imgPath );



jsp 代码:
String imgPath= (String)session.getAttribute("imgPath");
<img src='<%=imgPath>'></img>