Uploaded image for project: 'Struts 1'
  1. Struts 1
  2. STR-2665

document permitted form field names and provide a validation method

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.2.7
    • Fix Version/s: Future
    • Component/s: Documentation
    • Labels:
      None
    • Environment:
      Operating System: other
      Platform: Other
    • Bugzilla Id:
      37683

      Description

      Recently, I had to integrate with a portal that does a http form post into my
      struts application.

      Unfortunately, their field names (="action form bean properties") do not work
      with struts. Perhaps they are breaking some standard, but at least with some php
      environments, that was no problem.

      The following form field names were ok:

      • "card"
      • "IV"

      Problems arised with:

      • "PortalID"
      • "AuthValue"
      • "ServiceID"
      • "Created"

      Unfortunately, struts simply ignores these.
      The dirty fix is to manually extract them from the request parameters.

      Suggestions:
      1) document at the above help URL or within the
      org.apache.struts.action.ActionForm JavaDoc
      2) create a method that can be called during struts init() that
      a) takes all forms as declared in the struts-config.xml
      b) list the getter/setter properties that will not work!
      3) print a debug message for fields that could not be processed during operation
      (optionally)

      Since I also used the validator, at least there, the problems explicitly surfaced:
      <<Nov 28, 2005 3:41:09 PM org.apache.commons.validator.util.ValidatorUtils
      getValueAsString
      SEVERE: Unknown property 'ServiceID'
      java.lang.NoSuchMethodException: Unknown property 'ServiceID'
      at
      org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1122)
      at
      org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:686)
      at
      org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:715)
      at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:290)
      at
      org.apache.commons.validator.util.ValidatorUtils.getValueAsString(ValidatorUtils.java:105)
      at
      org.apache.struts.validator.FieldChecks.validateMaxLength(FieldChecks.java:812)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at
      org.apache.commons.validator.ValidatorAction.executeValidationMethod(ValidatorAction.java:567)
      at org.apache.commons.validator.Field.validateForRule(Field.java:827)
      at org.apache.commons.validator.Field.validate(Field.java:906)
      at org.apache.commons.validator.Form.validate(Form.java:174)
      at org.apache.commons.validator.Validator.validate(Validator.java:367)
      at org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java:110)
      at
      com.privasphere.privalope.util.PsphValForm.validateFromAction(PsphValForm.java:160)
      at
      com.privasphere.privalope.control.action.LoginTicketAction.execute(LoginTicketAction.java:128)
      at
      com.privasphere.privalope.control.action.LoginTicketAction.execute(LoginTicketAction.java:93)
      at
      org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
      at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
      at
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
      at
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:407)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:526)
      at
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:827)
      at
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
      at
      org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
      at
      org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
      at
      org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
      at java.lang.Thread.run(Thread.java:595)>>

      Luckily, I was able to convince them to change the form field names, but others
      might not be able to do that.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              hauser@acm.org Ralf Hauser
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: