0

I am passing body parameter that is text in different languages like French, German with special characters. I am using Javascript encode() to encode the body, the jsp page is UTF-8 encoded and on the servlet side I even tried using

request.setCharacterEncoding("UTF-8");

but still getting the below error from jboss before reaching the actual servlet body.

threw exception: java.lang.IllegalStateException: Parameters processing failed.
            at org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:407) [jbossweb-7.0.13.Final.jar:]
            at org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:229) [jbossweb-7.0.13.Final.jar:]
            at org.apache.catalina.connector.Request.parseParameters(Request.java:2874) [jbossweb-7.0.13.Final.jar:]
            at org.apache.catalina.connector.Request.getParameterNames(Request.java:1333) [jbossweb-7.0.13.Final.jar:]
            at org.apache.catalina.connector.Request.getParameterMap(Request.java:1313) [jbossweb-7.0.13.Final.jar:]
            at org.apache.catalina.connector.RequestFacade.getParameterMap(RequestFacade.java:422) [jbossweb-7.0.13.Final.jar:]
            at org.apache.struts2.dispatcher.Dispatcher.createContextMap(Dispatcher.java:592) [struts2-core-2.3.8.jar:2.3.8]
            at org.apache.struts2.dispatcher.ng.PrepareOperations.createActionContext(PrepareOperations.java:78) [struts2-core-2.3.8.jar:2.3.8]
            at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:78) [struts2-core-2.3.8.jar:2.3.8]
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
            at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
            at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_11]

On passing smaller text it works but if the body is long it throws the exception.

Passed value for body that fails:

K%E6re%20hr./fru%20%3Cbr%3E%3Cbr%3EVi%20bekr%E6fter%20hermed%2C%20at%20vi%20har%20modtaget%20din%20anmodning%20om%20at%20blive%20fjernet%20som%20modtager%20af%20Dells%20marketingmeddelelser%20den%20DD/MM/YYYY.%20%3Cbr%3E%3Cbr%3EVores%20marketingdatabase%20er%20blevet%20opdateret%20som%20f%F8lge%20af%20din%20anmodning.%20Der%20kan%20g%E5%20op%20til%2010%20arbejdsdage%20for%20e-mail%20og%204%20%u2013%206%20uger%20for%20direkte%20mail%2C%20f%F8r%20indstillingerne%20tr%E6der%20i%20kraft.%20Da%20nogle%20meddelelser%2C%20f.eks.%20direkte%20mail-kataloger%2C%20udvikles%20og%20s%E6ttes%20i%20k%F8%20til%20distribution%20l%E6nge%20i%20forvejen%2C%20vil%20du%20muligvis%20modtage%20flere%20oplysninger%2C%20efter%20at%20vi%20har%20modtaget%20din%20anmodning.%20%3Cbr%3E%3Cbr%3EVi%20er%20kede%20af%2C%20at%20du%20ikke%20l%E6ngere%20%F8nsker%20at%20modtage%20oplysninger%20om%20Dells%20produkter%20og%20services%2C%20men%20hvis%20du%20skulle%20ombestemme%20dig%20p%E5%20et%20senere%20tidspunkt%2C%20kan%20du%20bes%F8ge%20vores%20websted%3A%20www.dell.dk%20%3Cbr%3E%3Cbr%3EHvis%20du%20fortsat%20modtager%20marketingmeddelelser%20fra%20os%20efter%20de%20tidsrum%2C%20der%20er%20angivet%20ovenfor%2C%20er%20du%20altid%20velkommen%20til%20at%20kontakte%20os%20p%E5%20delldk@clientmail.eu.com.%20%3Cbr%3E%3Cbr%3EMed%20venlig%20hilsen%20%3Cbr%3E%3Cbr%3EDells%20kundeservice%20%3Cbr%3EDell%20Computer
Rahul Dhar
  • 61
  • 1
  • 9

2 Answers2

0

You may need to patch jboss-web.jar by changing Parameters.java. Try this, probably this may fix your problem.

https://community.jboss.org/message/747210

Update: This solution is not recommended, could be considered as a worst case scenario.

SyAu
  • 1,651
  • 7
  • 25
  • 47
  • From that discussion, "This isn't a bug in JBoss AS (or for that matter JBoss Web) code, so I won't be surprised if that JIRA gets rejected. The real fix should be in the application.". The real fix is not to patch server software, but to fix the application that's doing the wrong thing. – eis Mar 26 '13 at 07:05
  • I thought that was the issue I had found this JIRA. Turns out its the way I was sending the data over. I was able to fix this by using JQuery: encodeURIComponent($('
    ').text($('.jqte_editor').html()).html());
    – Rahul Dhar Mar 26 '13 at 15:29
  • @RahulDhar why have you accepted this answer even if this is not the fix you did? – eis Mar 28 '13 at 05:50
  • @eis I did run into this issue when I was just escaping the input text, resulting in parameter value as "&=&" that's when jboss threw the error without actually reaching the servlet. The JIRA above does address that problem. In case someone gets here looking for the solution. – Rahul Dhar Mar 29 '13 at 17:06
  • @RahulDhar um. advise to patch jboss-web.jar is simply wrong, like I explained in my answer and like you've done, correct way is to use encodeURIComponent/encodeURI. – eis Mar 30 '13 at 08:14
  • @eis Totally agree patching is not recommended. In my case also, IE9 sends &=& in query string and JBoss doesn't like it. Trying to fix my client side code which is responsible for this incorrect parameter in the query string. I will also update my answer. – SyAu Apr 01 '13 at 23:26
0

I am using Javascript encode() to encode the body

I think you mean escape(). Javascript escape function does not support UTF-8, there's encodeuricomponent and encodeuri that do support. Fix that and I would guess you'd be alright, assuming the source data is valid UTF-8.

Quoting this discussion, "Don't use it, as it has been deprecated since ECMAScript v3.".

Community
  • 1
  • 1
eis
  • 51,991
  • 13
  • 150
  • 199
  • I was using JS escape() changes it to JQuery: encodeURIComponent($('
    ').text($('#textBoxId').html()).html()); This escapes the html and encodeURIComponent takes care of the "&". It did work. Thanks
    – Rahul Dhar Mar 26 '13 at 15:20
  • encodeURIComponent is actually doing the escaping there, and it's not part of jquery. But anyway, glad it works now :) – eis Mar 26 '13 at 16:39