程序如下:
[b]testImg.jsp[/b]
<%@ page contentType="text/html;charset=GB2312"%>
<html>
    <body>
        <%
            String s=response.encodeURL("showImage.jsp");
            String imgName="98.jpg";
            session.setAttribute("Name",imgName);
        %>
        <form action="<%=s%>">
            <input type="submit" value="查看">
        </form>
    </body>
</html>

[b]showImage.jsp[/b]
<%@ page contentType="text/html;charset=GB2312"%>
<html>
    <body>
        <%
            String imageName=(String)session.getAttribute("Name");
            if(imageName==null)
                imageName="";
            out.print("<img src=http://localhost:8080/jsp/data/"+imageName+">");
            out.print("<br>"+imageName);
        %>
    </body>
</html>