0

Trying to validate the params sent via HttpServletRequest it seems that when accessing the request.JSON the params are deleted and cannot be accessed anymore.

More info here: https://github.com/grails/grails-core/issues/10035

How can I validate the values without causing the params to be deleted? I have tried cloning the HttpServletRequest object and then work with that but without success.

HttpServletRequest sreq = (HttpServletRequest) request
println(sreq.JSON) //from this point params are gone
Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156
Jacob
  • 3,580
  • 22
  • 82
  • 146
  • Request is in stream form so once you read stream data it does not remain there. For that you need to copy/clone data and read and again try to re-assign values to request. https://stackoverflow.com/questions/8522568/why-is-httpservletrequest-inputstream-empty – user3145373 ツ Feb 05 '18 at 13:12
  • You're not cloning anything, you're just defining another variable that points to the same instance. – Burt Beckwith Feb 05 '18 at 13:25
  • Yes I know..but also attempted cloning which I was unable to do... How can I solve this? – Jacob Feb 05 '18 at 13:27
  • Solved my problem using this sollution: https://stackoverflow.com/questions/10210645/http-servlet-request-lose-params-from-post-body-after-read-it-once – Jacob Feb 06 '18 at 09:43

0 Answers0