List of usage examples for javax.servlet.http HttpServletRequest getRequestURL
public StringBuffer getRequestURL();
From source file:net.smktarunabhakti.penjualan.ui.controller.BarangController.java
@RequestMapping(value = "/barang", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED)//from w w w.j ava 2 s . c om public void create(@RequestBody @Valid Barang x, HttpServletRequest request, HttpServletResponse response) { appService.simpanBarang(x); String requesturl = request.getRequestURL().toString(); URI uri = new UriTemplate("{requestUrl}/{id}").expand(requesturl, x.getId()); response.setHeader("location", uri.toASCIIString()); }
From source file:cmg.org.monitor.services.google.OAuth2CallbackServlet.java
@Override protected String getRedirectUri(HttpServletRequest request) throws ServletException, IOException { String redirectURL = request.getRequestURL().toString(); if (redirectURL.contains("/index.jsp")) { redirectURL = redirectURL.substring(0, redirectURL.lastIndexOf("/")); }// w w w.j a v a2s . c o m if (redirectURL.contains("/connect")) { redirectURL = redirectURL.substring(0, redirectURL.lastIndexOf("/")); } if (redirectURL.contains("/oauth2callback")) { redirectURL = redirectURL.substring(0, redirectURL.lastIndexOf("/")); } //return ConfigHelper.REDIRECT_URI; redirectURL += "/oauth2callback"; System.out.println("redirect URL: " + redirectURL); return redirectURL; }
From source file:cz.zcu.kiv.eegdatabase.webservices.rest.datafile.DataFileServiceController.java
/** * Builds URL for file download.// w w w . j a va 2 s . c o m * * @param request HTTP request * @param id data file id * @return URL string */ private String buildLocation(HttpServletRequest request, Object id) { StringBuffer url = request.getRequestURL(); UriTemplate ut = new UriTemplate(url.append("/{id}").toString()); return ut.expand(id).toASCIIString(); }
From source file:de.otto.jsonhome.controller.HtmlController.java
@RequestMapping(value = "/rel/**", method = RequestMethod.GET, produces = "text/html") public ModelAndView getRelationshipType(final HttpServletRequest request) { final URI relationTypeURI = URI.create(request.getRequestURL().toString()); final Map<String, Object> model = new HashMap<String, Object>(); model.put("contextpath", request.getContextPath()); final JsonHome jsonHome = jsonHomeSource.getJsonHome(); if (jsonHome.hasResourceFor(relationTypeURI)) { final ResourceLink resourceLink = jsonHome.getResourceFor(relationTypeURI); model.put("resource", resourceLink); if (resourceLink.isDirectLink()) { return new ModelAndView("directresource", model); } else {/*w w w .jav a2 s. c o m*/ return new ModelAndView("templatedresource", model); } } else { throw new IllegalArgumentException("Unknown relation type " + relationTypeURI); } }
From source file:com.amazon.dtasdk.v2.signature.Request.java
private String getFullURL(HttpServletRequest request) { StringBuffer requestURL = request.getRequestURL(); String queryString = request.getQueryString(); if (StringUtils.isEmpty(queryString)) { return requestURL.toString(); } else {/*from www. j av a 2 s. co m*/ return requestURL.append('?').append(queryString).toString(); } }
From source file:io.manasobi.security.UserDetailsController.java
@ExceptionHandler(MongoTimeoutException.class) public ModelAndView handleError(HttpServletRequest req, Exception exception) { ModelAndView mav = new ModelAndView(); mav.addObject("msg", exception); mav.addObject("url", req.getRequestURL()); mav.setViewName("error"); return mav;//from ww w . ja v a 2s . co m }
From source file:com.rakesh.rp3599.controller.ExceptionHandlingController.java
@ExceptionHandler({ Exception.class, AgencyNotFoundException.class }) public ModelAndView handleError(HttpServletRequest req, Exception exception) { ModelAndView mav = new ModelAndView(); mav.addObject("exception", exception); mav.addObject("url", req.getRequestURL()); mav.setViewName("error"); return mav;/*from w w w. j av a 2 s .c o m*/ }
From source file:org.chimi.s4s.controller.FileUploadController.java
private String[] createUrl(UploadResult uploadResult, HttpServletRequest request) { String url = request.getRequestURL().toString(); int hostEndIdx = url.indexOf('/', 7); String host = url.substring(0, hostEndIdx); String contextPath = request.getContextPath(); String[] urls = new String[2]; urls[0] = host + contextPath + "/file/" + uploadResult.getFileId(); if (uploadResult.isImage()) { urls[1] = host + contextPath + "/image/o/" + uploadResult.getFileId(); }/*ww w .j ava 2 s . c o m*/ return urls; }
From source file:de.otto.jsonhome.registry.controller.RegistryHtmlController.java
@RequestMapping(value = "/rel/**", method = RequestMethod.GET, produces = "text/html") public ModelAndView getRelationshipType( @RequestParam(required = false) @Doc(value = "The name of the json-home registry.") final String registry, final HttpServletRequest request) { final URI relationTypeURI = URI.create(request.getRequestURL().toString()); final String selectedRegistry = registry != null ? registry : defaultRegistry; final ResourceLink resourceLink = resourceLink(relationTypeURI, selectedRegistry); if (resourceLink != null) { final Map<String, Object> model = new HashMap<String, Object>(); model.put("contextpath", request.getContextPath()); model.put("resource", resourceLink); if (resourceLink.isDirectLink()) { return new ModelAndView("directresource", model); } else {/*from ww w . j av a2 s .c o m*/ return new ModelAndView("templatedresource", model); } } else { throw new IllegalArgumentException("Unknown relation type " + relationTypeURI); } }
From source file:com.pearson.pdn.demos.chainoflearning.CalendarServlet.java
@Override protected String getRedirectUri(HttpServletRequest req) throws ServletException, IOException { GenericUrl url = new GenericUrl(req.getRequestURL().toString()); url.setRawPath(req.getContextPath() + "/oauth2callback"); return url.build(); }