Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

jakarta allow cross origins

@Provider
public class CorsFilter implements ContainerResponseFilter {

    @Override
    public void filter(ContainerRequestContext requestContext, 
      ContainerResponseContext responseContext) throws IOException {
          responseContext.getHeaders().add(
            "Access-Control-Allow-Origin", "*");
          responseContext.getHeaders().add(
            "Access-Control-Allow-Credentials", "true");
          responseContext.getHeaders().add(
           "Access-Control-Allow-Headers",
           "origin, content-type, accept, authorization");
          responseContext.getHeaders().add(
            "Access-Control-Allow-Methods", 
            "GET, POST, PUT, DELETE, OPTIONS, HEAD");
    }
}
Comment

jakarta allow cross origins

@GET
@Path("/")
@Produces({MediaType.TEXT_PLAIN})
public Response index() {
    return Response
      .status(200)
      .header("Access-Control-Allow-Origin", "*")
      .header("Access-Control-Allow-Credentials", "true")
      .header("Access-Control-Allow-Headers",
        "origin, content-type, accept, authorization")
      .header("Access-Control-Allow-Methods", 
        "GET, POST, PUT, DELETE, OPTIONS, HEAD")
      .entity("")
      .build();
}
Comment

jakarta allow cross origins

@Provider
public class CorsFilter implements ContainerResponseFilter {

    @Override
    public void filter(ContainerRequestContext requestContext, 
      ContainerResponseContext responseContext) throws IOException {
          responseContext.getHeaders().add(
            "Access-Control-Allow-Origin", "*");
          responseContext.getHeaders().add(
            "Access-Control-Allow-Credentials", "true");
          responseContext.getHeaders().add(
           "Access-Control-Allow-Headers",
           "origin, content-type, accept, authorization");
          responseContext.getHeaders().add(
            "Access-Control-Allow-Methods", 
            "GET, POST, PUT, DELETE, OPTIONS, HEAD");
    }
}
Comment

jakarta allow cross origins

@GET
@Path("/")
@Produces({MediaType.TEXT_PLAIN})
public Response index() {
    return Response
      .status(200)
      .header("Access-Control-Allow-Origin", "*")
      .header("Access-Control-Allow-Credentials", "true")
      .header("Access-Control-Allow-Headers",
        "origin, content-type, accept, authorization")
      .header("Access-Control-Allow-Methods", 
        "GET, POST, PUT, DELETE, OPTIONS, HEAD")
      .entity("")
      .build();
}
Comment

PREVIOUS NEXT
Code Example
Java :: how to convert string to int android studio kotlin 
Java :: What Is Spring Boot and What Are Its Main Features? 
Java :: substring in java 
Java :: java create a random number 
Java :: java Sum of all the factors of a number 
Java :: java bean go to other page 
Java :: Java Catching base and child exception classes 
Java :: java scanner use all symbols as delimiter 
Java :: is type java 
Java :: how to create gravity in Java 
Java :: interfaces in java 
Java :: int cannot be converted to string error in java 
Java :: sudoku generator java code 
Java :: add words from string to collection java 
Java :: What are the design patterns involved in JDBC architecture? 
Java :: Java byte Keyword 
Java :: Java Documenting assumptions 
Java :: customize the androidx.appcompat.widget.SearchView site:stackoverflow.com 
Java :: java.applet defines how many interfaces 
Java :: Java socket connect to gmail 
Java :: java radom float 
Java :: raspberry stackexchange how to install the java jdk 
Java :: does java recognize on a txt file 
Java :: java i/o streams 
Java :: java mockito subclass mocken method 
Java :: Java take() Method 
Java :: this java 
Java :: Reference in java equal operator 
Java :: java random.nextint 
Java :: using new to create arrays 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =