<%@ page import="java.sql.ResultSet,
                 java.sql.Statement,
                 java.sql.Connection,
                 java.sql.DriverManager"%>
<%@ page contentType="text/xml;charset=UTF-8" language="java" %>
<?xml version="1.0" encoding="GB2312"?>
<students>
<%
    try{
        Class.forName("org.gjt.mm.mysql.Driver");
        //Á¬½ÓÊý¾Ý¿â
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost/test?user=root&characterEncoding=GBK");
        Statement stat = con.createStatement();
        String sql=null;
        sql="select * from student;";
        ResultSet result=stat.executeQuery(sql);
        while(result.next())
        {
%>

    <student>
        <sid><%=result.getString(1)%></sid>
        <name><%=result.getString(2)%></name>
        <gender><%=result.getString(3)%></gender>
        <age><%=result.getString(4)%></age>
        <grade><%=result.getString(5)%></grade>
        <major><%=result.getString(6)%></major>
    </student>
    <%
        }
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
    %>
</students>