String errorMsg = null;
    public int doStartTag() throws JspException {                try {            this.requestContext =                   new RequestContext((HttpServletRequest) this.pageContext.getRequest());        }        catch (RuntimeException ex) {            throw ex;        }        catch (Exception ex) {            pageContext.getServletContext().log("Exception in custom tag", ex);        }                // Look up this key to see if its a field of the current form        boolean requiredField = false;        boolean validationError = false;        ValidatorResources resources = getValidatorResources();                Locale locale = pageContext.getRequest().getLocale();        if (locale == null) {            locale = Locale.getDefault();        }                // get the name of the bean from the key        String formName = key.substring(0, key.indexOf('.'));        String fieldName = key.substring(formName.length() + 1);        if (resources != null) {            Form form = resources.getForm(locale, formName);            if (form != null) {                Field field = form.getField(fieldName);                if (field != null) {                    if (field.isDependency("required") || field.isDependency("validwhen")) {                        requiredField = true;                    }                }            }        }		Errors errors = requestContext.getErrors(formName, false);        List fes = null;        String errorMsg = null;        if (errors != null) {            fes = errors.getFieldErrors(fieldName);            errorMsg = getErrorMessages(fes);        }        // Retrieve the message string we are looking for        String message = null;        try {        	message = getMessageSource().getMessage(key, null, locale);        } catch (NoSuchMessageException nsm) {            message = "???" + key + "???";        }                String cssClass = null;        if (styleClass != null) {            cssClass = styleClass;        } else if (requiredField) {            cssClass = "required";        }        String cssErrorClass = (errorClass != null) ? errorClass : "error";        StringBuffer label = new StringBuffer();        if ((message == null) || "".equals(message.trim())) {            label.append("");        } else {            label.append("<label for=\"").append(fieldName).append("\"");            if (validationError) {                label.append(" class=\"").append(cssErrorClass).append("\"");            } else if (cssClass != null) {                label.append(" class=\"").append(cssClass).append("\"");            }            label.append(">").append(message);            label.append((requiredField) ? " <span class=\"req\">*</span>" : "");            label.append((colon) ? ":" : "");            label.append("</label>");                        if (fes != null && fes.size() > 0) {                label.append("<img class=\"validationWarning\" alt=\"");                label.append(getMessageSource().getMessage("icon.warning", null, locale));                label.append("\"");                String context = ((HttpServletRequest) pageContext.getRequest()).getContextPath();                label.append("src=\"" + context);                label.append(getMessageSource().getMessage("icon.warning.img", null, locale));                label.append("\" />");            }        }        // Print the retrieved message to our output writer        try {            writeMessage(label.toString());        } catch (IOException io) {            io.printStackTrace();            throw new JspException("Error writing label: " + io.getMessage());        }        // Continue processing this page        return (SKIP_BODY);    }