I am using Struts2 and request.getInputStream() can't be used, since it gives error on 2nd use, first might have already being used by any of the interceptors.
So, I believe there must be some way to get the request-body. But I didn't found anything on internet, please help.
As you say, the interceptor (I guess JSONInterceptor) has already done the job before for you. Probably you have a similar struts.xml structure:
struts.xml
Then, If you are trying to parse a JSON request like this:
You should have a Controller (or Action) like this:
In a
RequestAware/ServletRequestAwareAction you should access the request withrequest.getInputStream(), but when the JSONInterceptor acts, just let him do the work. Create as many fields as JSON elements want to be parsed in the Action/Controller. In this example I'm creating aString tokenfield (with it's setter and getter) to hold the content of the JSON element "token".When a /GET (with {"token":"mh5h6jrjkvnrk56"}) is done,
index()is called and the fieldtokenhas the value "mh5h6jrjkvnrk56" (as in the example).