List of usage examples for javax.servlet.http HttpServletRequest getPathInfo
public String getPathInfo();
From source file:com.seajas.search.attender.controller.ConfirmController.java
/** * Handle the request.// ww w .j a va2s .c o m * * @param request * @param model * @return String */ @RequestMapping(method = RequestMethod.GET) public String handleRequest(final HttpServletRequest request, final ModelMap model) throws Exception { String path = request.getPathInfo(); if (!StringUtils.isEmpty(path) && path.length() > 9) { String[] uuidParts = path.substring(9).split("/"); ProfileSubscriber subscriber; if (uuidParts.length > 1 && uuidParts[1].equalsIgnoreCase("disable")) subscriber = attenderService.unconfirmSubscriber(uuidParts[0]); else subscriber = attenderService.confirmSubscriber(uuidParts[0]); if (subscriber != null && uuidParts.length > 1 && uuidParts[1].equalsIgnoreCase("disable")) { model.put("uuid", uuidParts[0]); // TODO: Actually use the language in the JSPs model.put("language", subscriber.getEmailLanguage()); return "unconfirm"; } else if (subscriber != null) { Profile profile = attenderService.getProfileById(subscriber.getProfileId()); model.put("uuid", uuidParts[0]); model.put("profileUUID", profile.getUniqueId()); // TODO: Actually use the language in the JSPs model.put("language", subscriber.getEmailLanguage()); return "confirm"; } else { model.put("message", "Invalid confirmation ticket (" + uuidParts[0] + ") provided."); return "error"; } } else { model.put("message", "No confirmation ticket provided."); return "error"; } }
From source file:net.solarnetwork.node.setup.web.NodeAssociationFilter.java
private void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { final String path = request.getPathInfo(); if (!path.startsWith(NODE_ASSOCIATE_PATH) && identityService.getNodeId() == null) { response.sendRedirect(request.getContextPath() + NODE_ASSOCIATE_PATH); } else {/*from w w w. ja va 2 s . com*/ chain.doFilter(request, response); } }
From source file:org.cagrid.identifiers.namingauthority.impl.NamingAuthorityService.java
/** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse * response)/*from ww w . jav a 2s . c om*/ */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOG.debug("getPathInfo[" + request.getPathInfo() + "]"); LOG.debug("getQueryString[" + request.getQueryString() + "]"); LOG.debug("getRequestURI[" + request.getRequestURI() + "]"); LOG.debug("getRequestURL[" + request.getRequestURL() + "]"); LOG.debug("getServerName[" + request.getServerName() + "]"); LOG.debug("getServerPort[" + request.getServerPort() + "]"); LOG.debug("getServletPath[" + request.getServletPath() + "]"); LOG.debug("User Identity[" + request.getAttribute(GSIConstants.GSI_USER_DN)); processor.process(request, response); }
From source file:com.cloudera.oryx.als.serving.web.EstimateForAnonymousServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { CharSequence pathInfo = request.getPathInfo(); if (pathInfo == null) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No path"); return;// www . ja v a2s. co m } Iterator<String> pathComponents = SLASH.split(pathInfo).iterator(); String toItemID; Pair<String[], float[]> itemIDsAndValue; try { toItemID = pathComponents.next(); itemIDsAndValue = RecommendToAnonymousServlet.parseItemValuePairs(pathComponents); } catch (NoSuchElementException nsee) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, nsee.toString()); return; } if (itemIDsAndValue.getFirst().length == 0) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No items"); return; } String[] itemIDs = itemIDsAndValue.getFirst(); unescapeSlashHack(itemIDs); float[] values = itemIDsAndValue.getSecond(); OryxRecommender recommender = getRecommender(); try { float estimate = recommender.estimateForAnonymous(toItemID, itemIDs, values); Writer out = response.getWriter(); out.write(Float.toString(estimate)); out.write('\n'); } catch (NotReadyException nre) { response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, nre.toString()); } catch (NoSuchItemException nsie) { response.sendError(HttpServletResponse.SC_NOT_FOUND, nsie.toString()); } }
From source file:org.shredzone.commons.gravatar.GravatarCacheServlet.java
@Override protected void doService(HttpServletRequest req, HttpServletResponse resp) throws Exception { Matcher m = HASH_PATTERN.matcher(req.getPathInfo()); if (!m.matches()) { resp.sendError(HttpServletResponse.SC_NOT_FOUND); return;//from www .jav a2 s .com } String hash = m.group(1); GravatarService gs = getWebApplicationContext().getBean("gravatarService", GravatarService.class); File gravatarFile = gs.fetchGravatar(hash); long modifiedSinceTs = -1; try { modifiedSinceTs = req.getDateHeader("If-Modified-Since"); } catch (IllegalArgumentException ex) { // As stated in RFC2616 Sec. 14.25, an invalid date will just be ignored. } if (modifiedSinceTs >= 0 && (modifiedSinceTs / 1000L) == (gravatarFile.lastModified() / 1000L)) { // The image has not been modified since last request resp.sendError(HttpServletResponse.SC_NOT_MODIFIED); return; } long size = gravatarFile.length(); if (size > 0 && size <= Integer.MAX_VALUE) { // Cast to int is safe resp.setContentLength((int) size); } resp.setContentType("image/png"); resp.setDateHeader("Date", System.currentTimeMillis()); resp.setDateHeader("Last-Modified", gravatarFile.lastModified()); try (InputStream in = new FileInputStream(gravatarFile)) { FileCopyUtils.copy(in, resp.getOutputStream()); } }
From source file:org.atmosphere.samples.pubsub.spring.PubSubController.java
private void doPost(HttpServletRequest req) throws IOException { Broadcaster b = lookupBroadcaster(req.getPathInfo()); String message = req.getReader().readLine(); if (message != null && message.indexOf("message") != -1) { b.broadcast(message.substring("message=".length())); }/*from w w w. j av a 2s .co m*/ }
From source file:uk.ac.ox.oucs.vle.mvc.CourseSignupController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { ModelAndView modelAndView = new ModelAndView(request.getPathInfo().substring(1)); modelAndView.addObject("externalUser", userDirectoryService.getAnonymousUser().equals(userDirectoryService.getCurrentUser())); modelAndView.addObject("isAdministrator", !courseSignupService.getAdministering().isEmpty()); modelAndView.addObject("isApprover", !courseSignupService.getApprovals().isEmpty()); modelAndView.addObject("isPending", !courseSignupService.getPendings().isEmpty()); modelAndView.addObject("isLecturer", !courseSignupService.getLecturing().isEmpty()); modelAndView.addObject("skinRepo", serverConfigurationService.getString("skin.repo", "/library/skin")); modelAndView.addObject("skinDefault", serverConfigurationService.getString("skin.default", "default")); modelAndView.addObject("skinPrefix", serverConfigurationService.getString("portal.neoprefix", "")); return modelAndView; }
From source file:com.carolinarollergirls.scoreboard.jetty.StreamServlet.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { super.doGet(request, response); if (request.getPathInfo().equals("/list")) list(request, response);//from ww w. ja va2 s .c o m else response.sendError(HttpServletResponse.SC_NOT_FOUND); }
From source file:org.dspace.app.webui.cris.servlet.ResearcherPictureServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException { String idString = req.getPathInfo(); String[] pathInfo = idString.split("/", 2); String authorityKey = pathInfo[1]; Integer id = ResearcherPageUtils.getRealPersistentIdentifier(authorityKey, ResearcherPage.class); if (id == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return;/*from w w w . ja v a2 s. c om*/ } ResearcherPage rp = ResearcherPageUtils.getCrisObject(id, ResearcherPage.class); File file = new File(ConfigurationManager.getProperty(CrisConstants.CFG_MODULE, "researcherpage.file.path") + File.separatorChar + JDynATagLibraryFunctions.getFileFolder(rp.getPict().getValue()) + File.separatorChar + JDynATagLibraryFunctions.getFileName(rp.getPict().getValue())); InputStream is = null; try { is = new FileInputStream(file); response.setContentType(req.getSession().getServletContext().getMimeType(file.getName())); Long len = file.length(); response.setContentLength(len.intValue()); response.setHeader("Content-Disposition", "attachment; filename=" + file.getName()); FileCopyUtils.copy(is, response.getOutputStream()); response.getOutputStream().flush(); } finally { if (is != null) { IOUtils.closeQuietly(is); } } }
From source file:io.hawt.testing.env.builtin.EmptyJolokiaEnvironment.java
@Override public void handle(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setContentType("application/json"); resp.setCharacterEncoding("UTF-8"); if (req.getPathInfo().equals("")) { resp.getWriter().print(handle(RequestType.VERSION).toJSONString()); }/*w ww .j av a2s .c om*/ resp.getWriter().close(); }