List of usage examples for javax.servlet.http HttpServletRequest getContentType
public String getContentType();
null
if the type is not known. From source file:rapture.server.web.servlet.BaseReflexScriptPageServlet.java
private Map<String, Object> getRequestVariables(HttpServletRequest req) { Map<String, Object> serverMap = new HashMap<String, Object>(); serverMap.put("ContentType", req.getContentType()); serverMap.put("ContextPath", req.getContextPath()); serverMap.put("Method", req.getMethod()); serverMap.put("PathInfo", req.getPathInfo()); serverMap.put("RemoteAddr", req.getRemoteAddr()); serverMap.put("", req.getLocalAddr()); serverMap.put("Headers", getHeaderVariables(req)); serverMap.put("Attributes", getHeaderAttributes(req)); return serverMap; }
From source file:org.apache.shindig.social.core.oauth2.OAuth2NormalizedRequest.java
@SuppressWarnings("unchecked") public OAuth2NormalizedRequest(HttpServletRequest request) throws OAuth2Exception { super();//from w w w . j a v a 2 s .c o m setHttpServletRequest(request); String contentType = request.getContentType(); if (contentType != null) { Matcher match = FORM_URL_REGEX.matcher(contentType); if (match.matches()) { normalizeBody(getBodyAsString(request)); } } Enumeration<String> keys = request.getParameterNames(); while (keys.hasMoreElements()) { String key = keys.nextElement(); put(key, request.getParameter(key)); } normalizeClientSecret(request); normalizeAccessToken(request); }
From source file:controllers.FrameworkController.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); this.request = request; this.response = response; if (request.getContentType().contains("multipart/form-data")) { adicionarOuEditarFramework();//from w w w . j a v a2 s .com return; } if (request.getParameter("btn_editar") != null) { editarFramework(); return; } if (request.getParameter("btn_excluir") != null) { excluirFramework(); return; } }
From source file:org.esupportail.publisher.security.CustomSingleSignOutHandler.java
private boolean isMultipartRequest(final HttpServletRequest request) { return request.getContentType() != null && request.getContentType().toLowerCase().startsWith("multipart"); }
From source file:org.red5.server.net.servlet.AMFGatewayServlet.java
/** {@inheritDoc} */ @Override//from w w w . j a v a 2s .c o m public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (log.isDebugEnabled()) { log.debug("Remoting request" + req.getContextPath() + ' ' + req.getServletPath()); } if (req.getContentType() != null && req.getContentType().equals(APPLICATION_AMF)) { serviceAMF(req, resp); } else { resp.getWriter().write("Red5 : Remoting Gateway"); } }
From source file:org.primeframework.mvc.parameter.RequestBodyWorkflowTest.java
@Test public void noContentType() throws IOException, ServletException { HttpServletRequest request = createStrictMock(HttpServletRequest.class); expect(request.getParameterMap()).andReturn(null); expect(request.getContentType()).andReturn(null); replay(request);/* w w w .jav a 2 s.c o m*/ WorkflowChain chain = createStrictMock(WorkflowChain.class); chain.continueWorkflow(); replay(chain); RequestBodyWorkflow workflow = new RequestBodyWorkflow(request); workflow.perform(chain); verify(request, chain); }
From source file:org.primeframework.mvc.parameter.RequestBodyWorkflowTest.java
@Test public void wrongContentType() throws IOException, ServletException { HttpServletRequest request = createStrictMock(HttpServletRequest.class); expect(request.getParameterMap()).andReturn(null); expect(request.getContentType()).andReturn("text/xml"); replay(request);/*from www . j a v a 2 s . c om*/ WorkflowChain chain = createStrictMock(WorkflowChain.class); chain.continueWorkflow(); replay(chain); RequestBodyWorkflow workflow = new RequestBodyWorkflow(request); workflow.perform(chain); verify(request, chain); }
From source file:br.org.indt.ndg.servlets.PostResultsOpenRosa.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { m_openRosaBD.setPortAndAddress(SystemProperties.getServerAddress()); InputStreamReader inputStreamReader = new InputStreamReader(request.getInputStream(), "UTF-8"); boolean success = m_openRosaBD.parseAndPersistResult(inputStreamReader, request.getContentType()); DataOutputStream dataOutputStream = new DataOutputStream(response.getOutputStream()); if (success) { dataOutputStream.writeInt(SUCCESS); log.info("Successfully processed result stream from " + request.getRemoteAddr()); } else {// w ww. j a v a2s. c o m dataOutputStream.writeInt(FAILURE); log.error("Failed processing result stream from " + request.getRemoteAddr()); } dataOutputStream.close(); }
From source file:ee.ria.xroad.common.request.DummyCentralServiceHandler.java
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { log.info("Received request from {}", request.getRemoteAddr()); try {/* w w w . j ava 2s . c o m*/ SoapMessageImpl requestMessage = ManagementRequestHandler.readRequest(request.getContentType(), request.getInputStream()); log.info("Got request message: {}", requestMessage.getXml()); String service = requestMessage.getService().getServiceCode(); switch (service) { case "authCertRegRequest": handleAuthCertRegRequest(requestMessage, response); break; case "authCertDeletionRequest": handleAuthCertDeletionRequest(requestMessage, response); break; case "clientRegRequest": handleClientRegRequest(requestMessage, response); break; case "clientDeletionRequest": handleClientDeletionRequest(requestMessage, response); break; default: throw new RuntimeException("Unknown service " + service); } } catch (Exception e) { sendErrorResponse(response, translateException(e)); } finally { baseRequest.setHandled(true); } }
From source file:com.salmon.security.xacml.demo.springmvc.rest.controller.MarketPlacePopulatorController.java
@ExceptionHandler(HttpMessageNotReadableException.class) @ResponseStatus(HttpStatus.BAD_REQUEST)/* w w w.j a v a 2 s . c om*/ public void whenPayloadIsStrange(HttpServletRequest request, HttpMessageNotReadableException ex) { StringBuilder sb = new StringBuilder("REQUEST PARTS: "); LOG.info("************************ JSON ERROR ************************ "); LOG.info("ContentType " + request.getContentType()); LOG.info("ContentLength " + request.getContentLength()); StringBuffer jb = new StringBuffer(); String line = null; try { BufferedReader reader = request.getReader(); while ((line = reader.readLine()) != null) jb.append(line); } catch (Exception e) { /*report an error*/ } LOG.info("************************ JSON PARSING ************************ "); LOG.info("Payload: " + jb.toString()); try { ObjectMapper mapper = new ObjectMapper(); JsonFactory factory = mapper.getFactory(); JsonParser jp = factory.createParser(jb.toString()); JsonNode actualObj = mapper.readTree(jp); LOG.info("JSON OBJECT CREATED: " + actualObj.toString()); ObjectMapper driverMapper = new ObjectMapper(); Driver jsonDriver = driverMapper.readValue(actualObj.toString(), Driver.class); LOG.info("DRIVER OBJECT CREATED: " + jsonDriver.toString()); } catch (Exception e) { LOG.error("JSON Parsing Exception " + e.getMessage()); } }