List of usage examples for javax.servlet.http HttpServletRequest getAttribute
public Object getAttribute(String name);
Object
, or null
if no attribute of the given name exists. From source file:io.robusta.rra.controller.SpringController.java
/** * create a representation from the content of request's entity * /*from w ww . j a va 2 s. c o m*/ * @param req * @return */ public Representation getRepresentation(HttpServletRequest req) { return Rra.defaultRepresentation.createNewRepresentation(req.getAttribute("representation").toString()); }
From source file:ua.aits.sdolyna.controller.MainController.java
@RequestMapping(value = { "/500", "/Sdolyna/500" }) public ModelAndView error500(HttpServletRequest request, HttpServletResponse response) { Throwable exception = (Throwable) request.getAttribute("javax.servlet.error.exception"); String url = request.getRequestURL().toString() + "?" + request.getQueryString(); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); exception.printStackTrace(pw);//from ww w .java2s. c o m helpers.sendMail(url, sw.toString()); ModelAndView model = new ModelAndView("/error/500"); model.addObject("lan", "en"); TranslateElements translate = new TranslateElements("en"); model.addObject("lan", "en"); model.addObject("translate", translate); return model; }
From source file:com.thoughtworks.go.server.newsecurity.filters.X509AuthenticationFilter.java
private X509Certificate extractClientCertificate(HttpServletRequest request) { final X509Certificate[] certs = (X509Certificate[]) request.getAttribute(X509_HEADER_KEY); if (certs != null && certs.length > 0) { LOGGER.debug("Client certificate found in request: {}", certs[0]); return certs[0]; }/* w w w. j a v a 2 s.c o m*/ LOGGER.debug("No client certificate found in request."); return null; }
From source file:io.hops.hopsworks.api.jupyter.URITemplateProxyServlet.java
protected String rewriteQueryStringFromRequest(HttpServletRequest servletRequest, String queryString) { return (String) servletRequest.getAttribute(ATTR_QUERY_STRING); }
From source file:com.runwaysdk.web.SecureFileUploadServlet.java
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { ClientRequestIF clientRequest = (ClientRequestIF) req.getAttribute(ClientConstants.CLIENTREQUEST); boolean isMultipart = ServletFileUpload.isMultipartContent(req); if (!isMultipart) { // TODO Change exception type String msg = "The HTTP Request must contain multipart content."; throw new RuntimeException(msg); }//from w w w .j av a 2 s . c o m String fileId = req.getParameter("sessionId").toString().trim(); FileItemFactory factory = new ProgressMonitorFileItemFactory(req, fileId); ServletFileUpload upload = new ServletFileUpload(); upload.setFileItemFactory(factory); try { // Parse the request FileItemIterator iter = upload.getItemIterator(req); while (iter.hasNext()) { FileItemStream item = iter.next(); if (!item.isFormField()) { String fullName = item.getName(); int extensionInd = fullName.lastIndexOf("."); String fileName = fullName.substring(0, extensionInd); String extension = fullName.substring(extensionInd + 1); InputStream stream = item.openStream(); BusinessDTO fileDTO = clientRequest.newSecureFile(fileName, extension, stream); // return the vault id to the dhtmlxVault callback req.getSession().setAttribute("FileUpload.Progress." + fileId, fileDTO.getId()); } } } catch (FileUploadException e) { throw new FileWriteExceptionDTO(e.getLocalizedMessage()); } catch (RuntimeException e) { req.getSession().setAttribute("FileUpload.Progress." + fileId, "fail: " + e.getLocalizedMessage()); } }
From source file:de.micromata.genome.gwiki.page.impl.i18n.GWikiI18NCombinedResourceBundle.java
protected Object decorateWiki(GWikiI18nElement i18nel, String key, Object value) { if ((value instanceof String) == false && GWikiI18NServletFilter.HTTPCTX.get() == null) { return value; }//from ww w.java 2 s. c o m if (GWikiWeb.get() == null) { return value; } HttpServletRequest req = GWikiI18NServletFilter.HTTPCTX.get().getFirst(); if (ObjectUtils.toString(req.getAttribute("gwiki18ndeco")).equals("true") == false) { return value; } if (GWikiMessageTag.getDomId4I18N(req, key) != null) { return value; } GWikiWeb wikiWeb = GWikiWeb.get(); GWikiContext wikiContext = new GWikiContext(wikiWeb, GWikiServlet.INSTANCE, req, GWikiI18NServletFilter.HTTPCTX.get().getSecond()); if (GWikiWeb.get().getAuthorization().isAllowToEdit(wikiContext, i18nel.getElementInfo()) == false) { return value; } String contextPath = wikiWeb.getContextPath(); if (StringUtils.isEmpty(contextPath) == true) { contextPath = wikiContext.getRealContextPath(); } String gewikiBase = contextPath + wikiWeb.getServletPath(); String sval = (String) value; String ret = "<span class=\"gwiki18nk\" oncontextmenu=\"return gwikiI18NCtxMenu(this, '" + i18nel.getElementInfo().getId() + "', '" + key + "', '" + req.getRequestURI() + "', '" + gewikiBase + "')\">" + sval + "</span>"; return ret; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.commons.ChooseMasterDegreeToSelectCandidatesDA.java
private String getFromRequest(String parameter, HttpServletRequest request) { String parameterString = request.getParameter(parameter); if (parameterString == null) { parameterString = (String) request.getAttribute(parameter); }// w w w . j av a 2 s .c om return parameterString; }
From source file:com.pkrete.locationservice.admin.controller.rest.v1.AdminRestController.java
@RequestMapping(value = "/index", method = RequestMethod.POST, produces = "application/json; charset=utf-8") @ResponseBody//w w w. jav a 2s . c o m public Map indexGenerate(HttpServletRequest request) throws OperationFailedException { // Get operator id String operator = (String) request.getAttribute("operator"); // Message that's returned String message; if (request.getParameter("type") == null) { logger.warn("Indexing cannot be performed, because \"type\" parameter is missing. Operator : \"{}\".", operator); // Throw exception throw new OperationFailedException(getMessage("rest.error.parameter.missing")); } // Get index type that should be regenerated DocumentType type = this.parseType(request.getParameter("type")); if (type == DocumentType.LOCATION) { this.locationsService.recreateSearchIndex(); message = "Location index regenerated by \"" + operator + "\"."; } else if (type == DocumentType.LANGUAGE) { this.languagesService.recreateSearchIndex(); message = "Language index regenerated by \"" + operator + "\"."; } else if (type == DocumentType.OWNER) { this.ownersService.recreateSearchIndex(); message = "Owner index regenerated by \"" + operator + "\"."; } else { this.locationsService.recreateSearchIndex(); this.languagesService.recreateSearchIndex(); this.ownersService.recreateSearchIndex(); message = "Location, language and owner indexes regenerated by \"" + operator + "\"."; } logger.info(message); // Create Map containing the message Map result = new HashMap(); // Add message rest.admin.index.response result.put("message", getMessage("rest.admin.index.response")); // Return result return result; }
From source file:it.jugpadova.controllers.JuggerEditController.java
@ModelAttribute("timezones") protected List<TimeZoneBean> getTimezones(HttpServletRequest req) throws Exception { RequestContext rc = (RequestContext) req.getAttribute("requestContext"); List<TimeZoneBean> timezones = new ArrayList(); Date now = new Date(); String[] tzIds = TimeZone.getAvailableIDs(); for (Object otzId : tzIds) { String tzId = (String) otzId; TimeZone fdtz = TimeZone.getTimeZone(tzId); timezones.add(new TimeZoneBean(fdtz.getID(), fdtz.getID())); }/* w w w .j a v a 2 s . c o m*/ Collections.sort(timezones); return timezones; }
From source file:ErrorGen.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { //check the servlet exception Throwable throwable = (Throwable) request.getAttribute("javax.servlet.error.exception"); String servletName = (String) request.getAttribute("javax.servlet.error.servlet_name"); if (servletName == null) servletName = "Unknown"; String requestUri = (String) request.getAttribute("javax.servlet.error.request_uri"); if (requestUri == null) requestUri = "Unknown"; response.setContentType("text/html"); java.io.PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<head>"); out.println("<title>Error page</title>"); out.println("</head>"); out.println("<body>"); if (throwable == null) { out.println("<h2>The error information is not available</h2>"); out.println("Please return to the <a href=\"" + response.encodeURL("http://www.java2s.com") + "\">home page</a>"); } else {//from w w w .j a v a 2 s. c o m out.println("<h2>Here is the error information</h2>"); out.println("The servlet name associated with throwing the exception: " + servletName + "<br><br>"); out.println("The type of exception: " + throwable.getClass().getName() + "<br><br>"); out.println("The request URI: " + requestUri + "<br><br>"); out.println("The exception message: " + throwable.getMessage()); } out.println("</body>"); out.println("</html>"); out.close(); }