2

I have this code in my JSP:

<form:form commandName="Recipient" name="mailForm" 
           action="MailSuccess.jsp" method="get">
    <form:input path="toAddress"/>
    <form:input path="subject"/>
    <input type="submit" value="Send"/>
</form:form>

I am getting this error:

org.apache.jasper.JasperException: /SendMail.jsp(12,0) The form:form tag declares that it accepts dynamic attributes but does not implement the required interface

My guess is that I am missing some JAR file, but I am not sure. Can anyone provide some information for why this might happen?

Bogdan
  • 23,890
  • 3
  • 69
  • 61
Freakyuser
  • 2,774
  • 17
  • 45
  • 72

1 Answers1

6

You are indeed missing some JAR files or maybe you have them but are of the wrong version (I'm thinking the Spring jars that contain the tag handlers are wrong, maybe even wrongly included jsp-api.jar in your application).

You get that exception from the servlet container because it considers the Spring Form tag handler invalid.

In JSP 2.0 there is a new feature added to tag handlers that allow them to take dynamic attributes. For that to happen, you have to specify it in the TLD file with a <dynamic-attributes>true</dynamic-attributes> declaration and your tag handler class must implement the DynamicAttributes interface.

From the exception, its likely that your application loaded a JSP 2.0 Spring TLD file combined with an old version of the JAR that contains the org.springframework.web.servlet.tags.form.FormTag class.

You are not mentioning the Spring version you are using. Is it 3? Maybe it loaded a Spring 2 JAR which might happen if you are using Maven to get your application dependencies. That will make sense because the classes changed in between versions, so this will be the first thing I will check:

FormTag version 2: All Implemented Interfaces: Serializable, IterationTag, JspTag, Tag, TryCatchFinally, EditorAwareTag.

FormTag version 3: All Implemented Interfaces: Serializable, DynamicAttributes, IterationTag, JspTag, Tag, TryCatchFinally, EditorAwareTag.

Bogdan
  • 23,890
  • 3
  • 69
  • 61
  • Thank you very much. I removed the duplicate jars. Actually the class org.springframework.web.servlet.tags.form.FormTag you mentioned was in 2 of my jars. I removed spring2.0.6.jar and saved springwebmvc.jar. This did the trick. – Freakyuser Dec 03 '12 at 12:19
  • Is there any higher version of spring2.0.6.jar? Without this jar I am unable to use few classes. – Freakyuser Dec 03 '12 at 14:33
  • @Freakyuser: What version of Spring are you using and what are the classes you are refering to? – Bogdan Dec 03 '12 at 18:58