List of usage examples for javax.servlet.http HttpServletResponse getWriter
public PrintWriter getWriter() throws IOException;
PrintWriter
object that can send character text to the client. From source file:com.redip.servlet.nonconformity.NonConformityUpdateTable.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, JSONException { PrintWriter out = response.getWriter(); String id = request.getParameter("id"); int login = Integer.parseInt(id); int columnPosition = Integer.parseInt(request.getParameter("columnPosition")); String value = request.getParameter("value"); String columnName = request.getParameter("columnName"); Logger.log("NonConformityUpdate", Level.INFO, "id:" + login + ";value:" + value + ";columnName:" + columnName); ApplicationContext appContext = WebApplicationContextUtils .getWebApplicationContext(this.getServletContext()); IQualityNonconformitiesService nonconformitiesService = appContext .getBean(IQualityNonconformitiesService.class); IEmailService emailService = appContext.getBean(IEmailService.class); IFactoryQualityNonconformities factoryQNC = appContext.getBean(IFactoryQualityNonconformities.class); QualityNonconformities nonconformities = nonconformitiesService.getOneNonconformities(login); String str = nonconformitiesService.updateNonconformity(login, columnName, value); emailService.sendEmailEvent("update" + columnName, nonconformities, columnName, value); out.print(value);//from ww w. j a v a 2s.c o m }
From source file:edu.cornell.mannlib.vitro.webapp.controller.ajax.VitroAjaxController.java
protected void doError(HttpServletResponse response, String errorMsg, int httpstatus) { response.setStatus(httpstatus);/*from www.j a v a 2s. c o m*/ try { response.getWriter().write(errorMsg); } catch (IOException e) { log.debug("IO exception during output", e); } }
From source file:com.alzatezabala.fp.presentacion.controller.EntidadBancariaController.java
@RequestMapping(value = { "/EntidadBancaria" }) public void prueba(HttpServletRequest httpRequest, HttpServletResponse httpServletResponse) throws IOException { String jsonString = new JSONConverterImplJackson().toJSON(entidadBancariaDAO.findAll()); httpServletResponse.getWriter().println(jsonString); }
From source file:com.ebay.pulsar.analytics.spring.security.GlobalSecuritySettingTest.java
@Test public void testPlainTextBasicAuthenticationEntryPoint() throws IOException, ServletException { HttpServletRequest request = Mockito.mock(HttpServletRequest.class); HttpServletResponse response = Mockito.mock(HttpServletResponse.class); when(response.getWriter()).thenReturn(new PrintWriter(System.out)); PlainTextBasicAuthenticationEntryPoint point = new PlainTextBasicAuthenticationEntryPoint(); point.setRealmName("Test query"); point.commence(request, response, new AuthenticationException("Test Exception message") { /**/*from ww w . jav a2 s. co m*/ * */ private static final long serialVersionUID = 8643273901705238777L; }); }
From source file:org.mitre.secretsharing.server.FormJoinServlet.java
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Writer w = new HtmlXSSWriter(resp.getWriter()); try {/* w w w .ja v a 2s. co m*/ String parts = req.getParameter("parts"); if (parts == null) throw new RuntimeException("No secret parts provided"); boolean base64 = false; if (req.getParameter("base64") != null) base64 = Boolean.parseBoolean(req.getParameter("base64")); List<Part> partsBytes = new ArrayList<Part>(); for (String s : parts.split("\n")) { s = s.trim(); if (s.isEmpty()) continue; try { partsBytes.add(PartFormats.parse(s)); } catch (Exception e) { throw new RuntimeException("Corrupt key part \"" + s + "\"" + (e.getMessage() == null ? ": Improper encoding of secret parts" : ": " + e.getMessage()), e); } } Part[] p = partsBytes.toArray(new Part[0]); byte[] secret = p[0].join(Arrays.copyOfRange(p, 1, p.length)); if (base64) w.write(Base64Variants.MIME.encode(secret)); else w.write(new String(secret, "UTF-8")); } catch (Throwable t) { if (t.getMessage() != null) w.write("error: " + t.getMessage()); else w.write("error"); } }
From source file:MyServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { response.setContentType("text/html"); java.io.PrintWriter out = response.getWriter(); HttpSession session = request.getSession(); out.println("<html>"); out.println("<head>"); out.println("<title>Simple Session Tracker</title>"); out.println("</head>"); out.println("<body>"); out.println("<h2>Session Info</h2>"); out.println("session Id: " + session.getId() + "<br><br>"); out.println("The SESSION TIMEOUT period is " + session.getMaxInactiveInterval() + " seconds.<br><br>"); out.println("Now changing it to 20 minutes.<br><br>"); session.setMaxInactiveInterval(20 * 60); out.println("The SESSION TIMEOUT period is now " + session.getMaxInactiveInterval() + " seconds."); out.println("</body>"); out.println("</html>"); }
From source file:MyServlet.java
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); printHeader(out);// w w w .jav a2 s.c om printForm(out); printMessages(out); printFooter(out); }
From source file:ShoppingCartViewerRewrite.java
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.println("<HEAD><TITLE>Current Shopping Cart Items</TITLE></HEAD>"); out.println("<BODY>"); // Get the current session ID, or generate one if necessary String sessionid = req.getPathInfo(); if (sessionid == null) { sessionid = generateSessionId(); }// w w w . j a v a2 s .c o m // Cart items are associated with the session ID String[] items = getItemsFromCart(sessionid); // Print the current cart items. out.println("You currently have the following items in your cart:<BR>"); if (items == null) { out.println("<B>None</B>"); } else { out.println("<UL>"); for (int i = 0; i < items.length; i++) { out.println("<LI>" + items[i]); } out.println("</UL>"); } // Ask if the user wants to add more items or check out. // Include the session ID in the action URL. out.println("<FORM ACTION=\"/servlet/ShoppingCart/" + sessionid + "\" METHOD=POST>"); out.println("Would you like to<BR>"); out.println("<INPUT TYPE=SUBMIT VALUE=\" Add More Items \">"); out.println("<INPUT TYPE=SUBMIT VALUE=\" Check Out \">"); out.println("</FORM>"); // Offer a help page. Include the session ID in the URL. out.println("For help, click <A HREF=\"/servlet/Help/" + sessionid + "?topic=ShoppingCartViewerRewrite\">here</A>"); out.println("</BODY></HTML>"); }
From source file:com.buession.cas.web.controller.ValidateCaptchaController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { PrintWriter writer = response.getWriter(); writer.write(captchaService.validate(request, request.getParameter(requestParamName)) == true ? "true" : "false"); writer.close();// w w w . j av a2 s. co m return null; }
From source file:edu.lafayette.metadb.web.ImageZoom.java
/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) *///from www .j a v a 2s . co m protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); JSONObject output = new JSONObject(); try { String[] item = request.getParameter("item").split("-"); int index = Integer.parseInt(item[item.length - 1]); String projname = ""; for (int i = 0; i < item.length - 1; i++) { projname += item[i]; if (i != item.length - 2) projname += '-'; } String thumbPath = ItemsDAO.getThumbFilePath(projname, index); String thumbName = new File(thumbPath).getName(); String thumbFilePath = Global.PATH_PROJECT + projname + "/" + thumbName; String mediumPath = new File(ItemsDAO.getZoomDerivPath(projname, index)).getName(); String mediumFilePath = Global.PATH_PROJECT + projname + "/" + mediumPath; output.put("thumb", thumbFilePath); output.put("zoom", mediumFilePath); } catch (NumberFormatException e) { // No item number for zoom } catch (Exception e) { MetaDbHelper.logEvent(e); } out.print(output); out.close(); }