Allow cross domain java (CORS Filter)

Posted: September 30, 2013 in web

to allow cross doamin on clients using ajax just to the ff:

on your web.xml add these:

            <param-value>Origin, Accept, Content-Type,
        <!-- CORS Filter mapping -->

then add a dependency from com.thetransactioncompany : cors-filter

on my case it was cors-filter-1.7.1.jar


var xhr = $.ajax({
            type: "POST",
            url: "http://someserver:8080/services/account/test3",
            data: JSON.stringify({"nNumber":"2344"}),
            contentType: "application/json; charset=utf-8",
            dataType: "json",            
            beforeSend: function() {
            complete: function() {
            success: function(data) {
            error: function(d, msg) {

That’s it.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s