List of usage examples for javax.servlet.http HttpServletRequest getServletPath
public String getServletPath();
From source file:org.usergrid.rest.SwaggerServlet.java
public boolean handleJsonOutput(HttpServletRequest request, HttpServletResponse response) throws IOException { String path = request.getServletPath(); if (isEmpty(path)) { path = request.getPathInfo();/*from w w w . j a v a 2s . c o m*/ } if (isEmpty(path)) { return false; } path = path.toLowerCase(); if (pathToJson.containsKey(path)) { String json = pathToJson.get(path); if (json != null) { allowAllOrigins(request, response); if ("get".equalsIgnoreCase(request.getMethod())) { response.setContentType("application/json"); response.getWriter().print(json); return true; } } } return false; }
From source file:com.cubusmail.server.services.CubusmailServlet.java
@Override public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String fileName = request.getSession().getServletContext().getRealPath(request.getServletPath()); BufferedReader reader = new BufferedReader(new FileReader(fileName)); OutputStream outputStream = response.getOutputStream(); OutputStreamWriter writer = new OutputStreamWriter(outputStream); char[] inBuf = new char[1024]; int len = 0;/*from w w w. j a v a 2 s . c o m*/ try { while ((len = reader.read(inBuf)) > 0) { writer.write(inBuf, 0, len); } } catch (Throwable e) { log.error(e.getMessage(), e); } writer.flush(); writer.close(); outputStream.flush(); outputStream.close(); }
From source file:com.google.code.pathlet.web.PathletAjaxProcessor.java
/** * Retrieves the current request servlet path. * Deals with differences between servlet specs (2.2 vs 2.3+) * * @param request the request// w ww. j a v a 2 s. c o m * @return the servlet path */ private String getServletPath(HttpServletRequest request) { String servletPath = request.getServletPath(); if (ValueUtils.notEmpty(servletPath)) { return servletPath; } String requestUri = request.getRequestURI(); int startIndex = request.getContextPath().equals("") ? 0 : request.getContextPath().length(); int endIndex = request.getPathInfo() == null ? requestUri.length() : requestUri.lastIndexOf(request.getPathInfo()); if (startIndex > endIndex) { // this should not happen endIndex = startIndex; } return requestUri.substring(startIndex, endIndex); }
From source file:gov.nih.nci.caarray.web.filter.CasAuthenticationFilter.java
private boolean isExcludedUrl(HttpServletRequest request) { String servletPath = request.getServletPath(); for (String pattern : excludePatterns) { if (servletPath.matches(pattern)) { return true; }/*from ww w . j a v a2 s .c o m*/ } return false; }
From source file:org.openmrs.module.personalhr.web.controller.RedirectController.java
@Override public ModelAndView handleRequest(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { // default to the current path if (this.redirectView == null) { this.redirectView = request.getServletPath(); }//from www.j av a 2 s. c om return new ModelAndView(this.redirectView); }
From source file:com.ankang.report.resolver.AbstractReportResolver.java
protected void resolverParamter(HttpServletRequest request, String key) { if (null == request) { return;/*from ww w . j a v a2s .c om*/ } if (null != (params = sessionCache.get(request.getServletPath() + request.getQueryString() + key))) { return; } String parameter = getParameter(request, key); if (null == parameter) { return; } if (this.getClass().isAssignableFrom(XmlProtocolResolver.class)) { XMLSerializer xs = new XMLSerializer(); parameter = xs.read(parameter).toString(); } params = JSONObject.parseObject(parameter); sessionCache.put(request.getServletPath() + request.getQueryString() + key, params); }
From source file:eu.annocultor.tagger.server.controllers.SolrTaggerController.java
@RequestMapping("/doc/**/*.*") public void report(HttpServletRequest request, HttpServletResponse response) throws Exception { String path = merge(request.getServletPath(), request.getPathInfo()); path = path.substring("/doc".length()); response.setCharacterEncoding("UTF-8"); ServletOutputStream outputStream = response.getOutputStream(); try {// w ww. j a va 2 s . co m IOUtils.copy(new FileInputStream(new File(fetchDoc(), path)), outputStream); } finally { outputStream.close(); } }
From source file:controllers.ControladorFotoCoin.java
/** * Handles the HTTP <code>GET</code> method. * * @param request servlet request/*from ww w.j a v a2s .co m*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String userPath = request.getServletPath(); //pasar a jspf if (userPath.equals("/ControladorFotoCoin")) { int idMatch = Integer.parseInt(request.getParameter("idMatch")); request.setAttribute("idMatch", idMatch); userPath = "enviarFotoCoincidente"; } else if (userPath.equals("/Notificar")) { // int idMatch = Integer.parseInt(request.getParameter("idUsuario")); cuando se genere el match } String url = "WEB-INF/view/" + userPath + ".jspf"; RequestDispatcher rd = request.getRequestDispatcher(url); rd.forward(request, response); }
From source file:org.usergrid.rest.SwaggerServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String path = request.getServletPath(); logger.info("Swagger request: " + path); handleJsonOutput(request, response); }
From source file:com.mythesis.userbehaviouranalysis.RequestServlet.java
/** * Handles the HTTP <code>GET</code> method. * @param request servlet request// w ww . j a v a2 s . c o m * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String userPath = request.getServletPath(); String params = request.getQueryString().split("=")[1]; System.out.println("I'm going to send the analysis to " + request.getQueryString()); if (userPath.equals("/analysis")) { Mongo mongo = new Mongo("localhost", 27017); DB db = mongo.getDB("profileAnalysis"); DBCollection userinfo = db.getCollection("history"); BasicDBObject searchQuery = new BasicDBObject(); searchQuery.put("userID", params); DBCursor cursor = userinfo.find(searchQuery); if (cursor.hasNext()) { String entry = cursor.next().toString(); System.out.println(entry); response.setHeader("Access-Control-Request-Method", "GET"); response.setContentType("application/json"); response.getWriter().write(entry); } } }