<h3><m:student_yetagain>Joe Jones</m:student_yetagain></h3>  

(EVAL_BODY_BUFFERED again) - The Students information is Name: Joe Jones Year: Senior Grade: 85


package mytags;  
import javax.servlet.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.util.*;
import java.sql.*;  

public class GetStudentyetagain extends BodyTagSupport {
    static String name;
    private String theoutput="smith";
    private JspWriter out;
    private BodyContent b=null;
    static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";  
    static final String DB_URL = "jdbc:mysql://localhost/cs4010";
    static final String USER = "cs4010";
    static final String PASS = "cs4010";

    public int doStartTag() throws JspException {  
        out=pageContext.getOut();  
        try {
            b=getBodyContent();
            GetStudentyetagain.name = getBodyContent().getString();
            out.print("(<font color='BLUE'>EVAL_BODY_BUFFERED</font> again) - The Students information is ");  
        } catch (Exception e) {
            e.printStackTrace();
        }
        return EVAL_BODY_BUFFERED;  
    }
    public void setBodyContent(BodyContent b) {
        this.bodyContent = b;
    }


    public void doInitBody()throws JspException {
        try {

            theoutput=TheStudent("Joe Jones");    
        } catch (Exception e) {
            theoutput="jones";
            try {
                out.print("here");
            } catch (Exception e1) {
            }
        }
        return ;  
    }
    public int doAfterBody()throws JspException {
        try {
            out.print(theoutput);  
        } catch (Exception e) {
            try {
                out.print("here");
            } catch (Exception e1) {
            }
        }
        return SKIP_BODY;  
    }

    public String TheStudent(String who){
        Connection conn = null;
        Statement stmt = null;
        String theReturn="";
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection(DB_URL,USER,PASS);
            stmt = conn.createStatement();
            String this_query="SELECT name, year, test FROM student where name=\"";
            this_query=this_query+who+"\";";
            ResultSet rs = stmt.executeQuery(this_query);
            while (rs.next()) {
                String the_name  = rs.getString("name");               
                String the_year = rs.getString("year");
                int the_grade = rs.getInt("test");
                theReturn="Name: " + the_name + " Year: "+the_year+" Grade: "+the_grade;
            }
            rs.close();
            stmt.close();
            conn.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return theReturn;
    }
}