protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String physicalPath = getServletContext().getRealPath("") + File.separator + "WEB-INF" + File.separator + "classes" + File.separator + "com"
+ File.separator + "lbslocal" + File.separator + "api" + File.separator + "scripts";
ConfigurationManager cm = ConfigurationManager.getInstance();
com.lbslocal.master.common.ConfigurationManager cmMaster = com.lbslocal.master.common.ConfigurationManager.getInstance();
ControlJavaScriptAPI memoryAPI = new ControlJavaScriptAPI(physicalPath, cmMaster.getAppSettings("PATH_FILE_API"));
String AcceptEncoding, versionApi, engine, api, debug;
boolean useGZip = true;
engine = request.getParameter("engine") == null ? "" : request.getParameter("engine");
versionApi = request.getParameter("v") == null ? "3" : request.getParameter("v");
debug = request.getParameter("debug") == null ? "" : request.getParameter("debug");
ServletOutputStream out = null;
File file;
RandomAccessFile raf = null;
try {
response.setContentType("application/x-javascript");
AcceptEncoding = request.getHeader("Accept-Encoding");
// *** Start by checking whether GZip is supported by client
if (AcceptEncoding == null || AcceptEncoding.toLowerCase().indexOf("gzip") == -1)
useGZip = false;
api = "v" + versionApi + engine.toLowerCase();
// é uma chamada de debug?
if ("true".equals(cm.getAppSettings("debugJS")) || debug.equals("true")) {
response.setHeader("Content-Encoding", "UTF-8");
file = memoryAPI.getAPI(api, ControlJavaScriptAPI.Debug);
} else {
// é possivel usar o gzip?
if (useGZip) {