Class 2 Intermediate Java 30-IT-397  

DealerUp.java

package blackjack;

// import the necessary libraries.
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
import java.lang.*;

/**
 * Simple custom JSP tag that prints a copyright where inserted.
 *
 * 12/18/2001 jonesbr@email.uc.edu
 **/

public class DealerUp extends BodyTagSupport {

 
    /**
     * method doAfterBody
     *
     * Gets the value of the dealer's up card.
     *
     * @author jonesbr@email.uc.edu
     * date December 30, 2001
     */
 
    public int doAfterBody() {
        try {
            // Get the BodyContent object to manipulate the body.
            BodyContent body = getBodyContent();

            Play parent = (Play)findAncestorWithClass(this, Play.class);
            parent.setDealerValue(Integer.parseInt(body.getString().trim()));
            // parent.setDealerValue(6);
 
            JspWriter out = body.getEnclosingWriter();
            out.print("Dealer Total: " + body.getString() + "<br>");
 
        } catch (Exception e) {
            System.out.println("Exception in Replace " + e);
        }
        // Let them know I'm finished.
        return(SKIP_BODY);
    }
 
// End the class.
}

 Back

Created by:  Brandan Jones December 17, 2001