List of usage examples for javax.servlet.http HttpServletResponse setContentType
public void setContentType(String type);
From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Admin.CRUDUsuarios.java
protected static void obtenerTotalUsuarios(HttpServletRequest request, HttpServletResponse response) throws IOException { int numC = CtrlAdmin.obtenerTotalUsuarios(); response.setContentType("application/json;charset=UTF-8"); PrintWriter out = response.getWriter(); JSONObject obj = new JSONObject(); obj.put("total", numC); out.print(obj);// w ww. j av a2 s.com }
From source file:com.cueup.hegemon.testing.server.HegemonTestServer.java
private static void markHandled(Request baseRequest, HttpServletResponse response, int status, String contentType) {/*from w w w . j av a 2 s . c om*/ response.setContentType(contentType + ";charset=utf-8"); response.setStatus(status); baseRequest.setHandled(true); }
From source file:com.berrysys.ussdgw.HttpUtils.java
/** * Queue full logic.//from ww w . j a va 2 s .c o m * * @param resp the resp * @throws IOException Signals that an I/O exception has occurred. */ private static void queueFullLogic(HttpServletResponse resp) throws IOException { // TODO Auto-generated method stub String response = "Message Queue full"; resp.setContentType("text/html"); resp.setStatus(HttpServletResponse.SC_OK); resp.getWriter().println(response); }
From source file:com.txtweb.wikipedia.Wikipedia.java
private static void sendResponse(HttpServletResponse httpResponse, String response) { try {//from ww w .j a v a2s . com httpResponse.setContentType("text/html; charset=UTF-8"); PrintWriter out = httpResponse.getWriter(); // Add all the surrounding HTML String htmlResponse = "<html><head><title>Wikipedia</title>" + "<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />" + "<meta name='" + APPKEY_NAME + "' content='" + APPKEY_CONTENT + "' />" + "</head><body>" + response + "</body></html>"; out.println(htmlResponse); } catch (IOException e) { // } }
From source file:de.xwic.appkit.webbase.modules.ModuleProviderServlet.java
/** * 200 and send content// www . j a va 2s .com * * @param content * @param response * @throws IOException * @throws JSONException */ private static void ok(JSONObject content, HttpServletResponse response) throws IOException, JSONException { response.setStatus(HttpServletResponse.SC_OK); response.setContentType("application/json"); response.getWriter().println(content.toString(2)); }
From source file:com.age.core.utils.web.ServletUtils.java
/** * ?xml?//from w ww . j ava 2s .com * @param response * @param object */ public static void responseXml(HttpServletResponse response, String xml) { try { response.setContentType("text/xml"); response.getWriter().write(xml); response.getWriter().flush(); response.getWriter().close(); } catch (IOException e) { } }
From source file:edu.cornell.mannlib.vitro.webapp.controller.ajax.SparqlUtils.java
public static void executeQuery(HttpServletResponse response, Query query, Model model) throws IOException { Dataset dataset = DatasetFactory.create(model); QueryExecution qe = QueryExecutionFactory.create(query, dataset); try {/*from w ww . j a v a2s . c o m*/ ResultSet results = qe.execSelect(); response.setContentType(RESPONSE_MIME_TYPE); OutputStream out = response.getOutputStream(); ResultSetFormatter.outputAsJSON(out, results); } finally { qe.close(); } }
From source file:gov.nist.appvet.tool.sigverifier.util.ReportUtil.java
/** * This method returns report information to the AppVet ToolAdapter as ASCII * text and cannot attach a file to the response. *//*from www.j av a2s .c o m*/ public static boolean sendInHttpResponse(HttpServletResponse response, String reportText, ToolStatus reportStatus) { try { response.setStatus(HttpServletResponse.SC_OK); // HTTP 200 response.setContentType("text/html"); response.setHeader("toolrisk", reportStatus.name()); PrintWriter out = response.getWriter(); out.println(reportText); out.flush(); out.close(); log.debug("Returned report"); return true; } catch (IOException e) { log.error(e.toString()); return false; } }
From source file:org.openmrs.module.omodexport.util.OmodExportUtil.java
/** * Utility method for exporting a single module * /*from w ww .j a v a 2 s . c o m*/ * @param module -The module to export * @param response */ public static void exportSingleModule(Module module, HttpServletResponse response) { File file = module.getFile(); response.setContentLength(new Long(file.length()).intValue()); response.setContentType("application/zip"); response.setHeader("Content-Disposition", "attachment; filename=\"" + file.getName() + "\""); try { FileCopyUtils.copy(new FileInputStream(file), response.getOutputStream()); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.myjerry.util.ResponseUtil.java
public static final ModelAndView sendFileToDownload(HttpServletResponse response, String fileToDownload, String fileName, String contentType, boolean isHttp11) throws IOException { response.reset();/* w w w . j a v a 2 s . c o m*/ setNoCache(response, isHttp11); response.setHeader("Content-Disposition", "attachment; filename=" + fileName); response.setContentType(contentType); ServletOutputStream out; out = response.getOutputStream(); out.print(fileToDownload); out.flush(); out.close(); return null; }