Hi,
We have a rails app, from which i want to send the form post parameters
to a java class.
I am using
request.env[‘java.servlet_request’]
to get the HttpServletRequest obj and pass it to the java class.
However it is unable to get the request parameters which are sent
through post.
If I pass the parameters as query parameters I am able to get them,
however I
am unable to get the form Post parameters
I also tried using
servlet_request
but that doesnt help either.
Is there any way aroung it?
Thank you.
On Wed, Aug 25, 2010 at 7:08 AM, Prachi T. [email protected]
wrote:
Is there any way aroung it?
What version of JRuby-Rack are you using? This sounds like a variation
on a earlier bug where once we read the request post body, it’s no
longer available to others. It may still exist in your case because
JRuby-Rack reads the post body, tries to rewind the Ruby IO object
wrapping the input stream, but perhaps the servlet input stream cannot
be rewound at all.
In this case I suggest you pass a servlet request wrapper to the Java
code as follows (note, untested):
java_import javax.http.servlet.HttpServletRequestWrapper
class RubyRequestWrapper < HttpServletRequestWrapper
class ArrayEnumeration
include java.util.Enumeration
def hasMoreElements
def initialize(request)
super(request.env[‘java.servlet_request’])
@request = request
end
def getParameter(key)
request.params[key]
end
def getParameterNames
request
end
end
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
Sorry, my email got cut off accidentally as I was writing the code.
Should’ve written the whole thing in a proper text editor
On Wed, Aug 25, 2010 at 10:37 AM, Nick S. [email protected]
wrote:
to get the HttpServletRequest obj and pass it to the java class.
but that doesnt help either.
In this case I suggest you pass a servlet request wrapper to the Java
code as follows (note, untested):
Here’s the code, hopefully it gives you an idea:
/Nick
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
On 25 August 2010 18:45, Nick S. [email protected] wrote:
to a java class.
If I pass the parameters as query parameters I am able to get them,
however I
am unable to get the form Post parameters
I also tried using
servlet_request
but that doesnt help either.
Is there any way aroung it?
I think it might just be a limitation described in the servlet spec.
http://download.oracle.com/javaee/1.3/api/javax/servlet/ServletRequest.html#getParameter(java.lang.String)