Skip to content

Instantly share code, notes, and snippets.

View atilacamurca's full-sized avatar

Átila Camurça Alves atilacamurca

View GitHub Profile
@atilacamurca
atilacamurca / Api.java
Created March 10, 2014 17:20
Cross Site Access via JSONP
public abstract class Api extends HttpServlet {
protected void responder(JSONObject resultado, HttpServletResponse response, String callback) {
try {
response.setContentType("text/javascript;charset=utf-8");
response.setHeader("Access-Control-Allow-Headers", "Content-Type, x-xsrf-token");
PrintWriter out = response.getWriter();
String saida = callback + "(" + resultado + ");";
out.print(saida);
} catch (IOException e) {