<%--List8_3_1.jsp--%>
<%@page contentType="text/html; charset=GBK"%>
<%@page import="java.io.*"%>
<html>
    <head><title>访问类路径上的资源</title></head>
    <body bgcolor="#ffffff">
    <%
        String fname=pageContext.getServletContext().getRealPath("8_3_1.txt");
        File file = new File(fname);
        FileReader fr = null;
        BufferedReader br=null;

        try {
            fr = new FileReader(file);
            br = new BufferedReader(fr);
            String line;
            while((line = br.readLine()) != null) {
                out.println(line);
                out.println("</br>");
            }
            fr.close();
            br.close();
        } catch (Exception e) { //捕获文件读写异常，输出在页面上
            out.println(e.getMessage());
        }
    %>
    </body>
</html>
