This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

--Using REST services with CORS

Documents for the development of and with JVx.

--Using REST services with CORS

Postby Development@SIB » Tue Jun 16, 2015 3:32 pm



This article is outdated - please use our new system at

https://doc.sibvisions.com




Details about CORS.

JVx' REST services support CORS since RESTlet update to 2.3.2. This version has the class CorsFilter which handles CORS automatically.

CORS support is disabled by default. If you want to call your REST service from "another domain", simply enable CORS via web.xml:

Syntax: [ Download ] [ Hide ]
  <!--
  **************************************************************************
   REST support
  **************************************************************************
  -->

  <!-- Restlet adapter -->  
  <servlet>  
    <servlet-name>RestletServlet</servlet-name>  
    <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
   
    <init-param>
      <!-- Application class name -->
      <param-name>org.restlet.application</param-name>
      <param-value>com.sibvisions.rad.server.http.rest.RESTAdapter</param-value>
    </init-param>
   
    <init-param>
      <param-name>cors.origin</param-name>
      <param-value>*</param-value>
    </init-param>
   
  </servlet>  
 
  <servlet-mapping>  
    <servlet-name>RestletServlet</servlet-name>  
    <url-pattern>/services/rest/*</url-pattern>  
  </servlet-mapping>

The init parameter cors.origin takes a comma separated list or simply * (for all sites).
User avatar
Development@SIB
 
Posts: 325
Joined: Mon Sep 28, 2009 1:54 pm

Return to Documentation