Sunday, December 11, 2011

URIEncoding in JBOSS7

Old Jboss type style  like following in Jboss7 is no more and you will have to add in system properties:


Old way: <Connector name="http" ... URIEncoding="UTF-8" useBodyEncodingForURI="true"/>
 This can be edited in standalone.xml file to take effect in old way

New Way:

In Jboss7 there are 2 methods by which you can add these:

Method 1:

Using the jboss-admin.sh adn updating the system-property like:

[standalone@amghost3.cup.com:9009 /] 
/system-property=org.apache.catalina.connector.URI_ENCODING:add(value="UTF-8")
{"outcome" => "success"}


[standalone@amghost3.cup.com:9009 /] 
/system-property=org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING:add(value="true")
{"outcome" => "success"}
[standalone@amghost3.cup.com:9009 /] 

Verify these property by:

[standalone@amghost3.cup.com:9009 /]  /system-property=org.apache.catalina.connector.URI_ENCODING:read-resource
{
    "outcome" => "success",
    "result" => {"value" => "UTF-8"}
}
[standalone@amghost3.cup.com:9009 /] 

[standalone@amghost3.cup.com:9009 /]  /system-property=org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING:read-resource
{
    "outcome" => "success",
    "result" => {"value" => "true"}
}
[standalone@amghost3.cup.com:9009 /] 


Method 2:

cd $JBOSS_HOME/standalone/configuration

vi standalone.xml   ad add the following lines just below the </extensions>

    <system-properties>
        <property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/>
        <property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="tru
e"/>
    </system-properties>


Hope this Helps.

No comments:

Post a Comment