List of usage examples for javax.servlet.http HttpServletRequest getReader
public BufferedReader getReader() throws IOException;
BufferedReader
. From source file:org.wicketstuff.rest.utils.http.HttpUtils.java
/** * Read the string content of the current request. * //from w w w.ja v a2 s .c o m * @param request * the current request * @return the string inside body request. * @throws IOException */ public static String readStringFromRequest(WebRequest request) throws IOException { HttpServletRequest httpRequest = (HttpServletRequest) request.getContainerRequest(); return IOUtils.toString(httpRequest.getReader()); }
From source file:com.jjtree.utilities.JConverter.java
public static JSONObject convert(HttpServletRequest request) throws IOException { StringBuilder sb = new StringBuilder(); BufferedReader reader = request.getReader(); try {/*from ww w . jav a 2 s . c o m*/ String line; while ((line = reader.readLine()) != null) { sb.append(line).append('\n'); } } finally { reader.close(); } JSONObject jsonObject = null; try { jsonObject = new JSONObject(sb.toString()); } catch (JSONException ex) { Logger.getLogger(JConverter.class.getName()).log(Level.SEVERE, null, ex); } return jsonObject; }
From source file:com.intbit.util.ServletUtil.java
public static Map<String, Object> getJsonFromRequestBody(HttpServletRequest request) throws IOException { return AppConstants.GSON.fromJson(new BufferedReader(request.getReader()), Map.class); }
From source file:org.eclipse.rtp.httpdeployer.internal.HttpDeployerUtils.java
public static Document parseXmlRequest(HttpServletRequest request) throws JDOMException, IOException { SAXBuilder builder = new SAXBuilder(); Document xmlDocument = builder.build(request.getReader()); return xmlDocument; }
From source file:com.reydentx.core.common.JSONUtils.java
public static <T> T fromJson(HttpServletRequest req, Type type) { try {/* w ww .ja va2s . c o m*/ return GSON.fromJson(req.getReader(), type); } catch (Exception ex) { _logger.error(ex.getMessage(), ex); } return null; }
From source file:com.zextras.zimbradrive.BackendUtils.java
public static Map<String, String> getJsonRequestParams(HttpServletRequest httpServletRequest) throws IOException { String body = IOUtils.toString(httpServletRequest.getReader()); List<NameValuePair> requestParameters = URLEncodedUtils.parse(body, StandardCharsets.UTF_8); Map<String, String> paramsMap = new HashMap<String, String>(); for (NameValuePair item : requestParameters) { paramsMap.put(item.getName(), item.getValue()); }//from w w w. java2 s . c om return paramsMap; }
From source file:com.claresco.tinman.servlet.XapiServletUtility.java
protected static BufferedReader getReader(HttpServletRequest req) throws XapiServletOperationProblemException { try {//from ww w . j av a 2 s . com return req.getReader(); } catch (IOException e) { throw new XapiServletOperationProblemException("Having problem reading the request"); } }
From source file:com.tang.util.RequestBeanKit.java
/** * ?ajax????bean//from w ww. j av a2 s . c o m * @param request * @param valueType * @param <T> * @return */ public static <T> T getRequestObject(HttpServletRequest request, Class<T> valueType) { StringBuilder json = new StringBuilder(); try { BufferedReader reader = request.getReader(); String line = null; while ((line = reader.readLine()) != null) { json.append(line); } reader.close(); } catch (Exception e) { } System.out.println(json.toString()); return JSONObject.parseObject(json.toString(), valueType); }
From source file:com.roncoo.pay.utils.JsonUtils.java
/** * Json???Json//w w w. java2 s.c o m * @param httpServletRequest * @return */ public static JSONObject requestJson(HttpServletRequest httpServletRequest) { StringBuffer buffer = new StringBuffer(); String line = null; JSONObject jsonObject = null; try { BufferedReader reader = httpServletRequest.getReader(); while ((line = reader.readLine()) != null) { buffer.append(line); } reader.close(); jsonObject = JSONObject.parseObject(buffer.toString()); } catch (Exception e) { LOG.error(e); } return jsonObject; }
From source file:dk.dma.msinm.common.util.WebUtils.java
/** * Reads the body of a posted request//from ww w. j a v a2 s. c o m * @param request the request * @return the body */ public static String readRequestBody(HttpServletRequest request) throws IOException { StringBuilder result = new StringBuilder(); String line; BufferedReader reader = request.getReader(); while ((line = reader.readLine()) != null) { result.append(line).append("\n"); } return result.toString(); }