Which tag handler method will accomplish this goal?

You are creating a library of custom tags that mimic the HTML form tags. When the user submits a form that fails validation, the JSP form is forwarded back to the user. The <t:textField> tag must support the ability to re-populate the form field with the request parameters from the user’s last request. For example, if the user entered "Samantha" in the text field called firstName, then the form is re-populated like this:
<input type=’text’ name=’firstName’ value=’Samantha’ />
Which tag handler method will accomplish this goal?
A. public int doStartTag() throws JspException {
JspContext ctx = getJspContext();
String value = ctx.getParameter(this.name);
if ( value == null ) value = "";
JspWriter out = pageContext.getOut();
try {
out.write(String.format(INPUT, this.name, value));
} (Exception e) { throw new JspException(e); }
return SKIP_BODY;
}
private static String INPUT = "<input type=’text’ name=’%s’ value=’%s’ />";
B. public void doTag() throws JspException {
JspContext ctx = getJspContext();
String value = ctx.getParameter(this.name);
if ( value == null ) value = "";
JspWriter out = pageContext.getOut();
try {
out.write(String.format(INPUT, this.name, value));
} (Exception e) { throw new JspException(e); }
}
private static String INPUT = "<input type=’text’ name=’%s’ value=’%s’ />";
C. public int doStartTag() throws JspException {
ServletRequet request = pageContext.getRequest();
String value = request.getParameter(this.name);
if ( value == null ) value = "";
JspWriter out = pageContext.getOut();
try {
out.write(String.format(INPUT, this.name, value));
} (Exception e) { throw new JspException(e); }
return SKIP_BODY;
}
private static String INPUT= "<input type=’text’ name=’%s’ value=’%s’ />";
D. public void doTag() throws JspException {
ServletRequet request = pageContext.getRequest();
String value = request.getParameter(this.name);
if ( value == null ) value = "";
JspWriter out = pageContext.getOut();
try {
out.write(String.format(INPUT, this.name, value));
} (Exception e) { throw new JspException(e); }
}
private static String INPUT = "<input type=’text’ name=’%s’ value=’%s’ />";

Download Printable PDF. VALID exam to help you PASS.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.