List of usage examples for javax.servlet.http HttpServletRequest getSession
public HttpSession getSession();
From source file:edu.umich.its.lti.TcSiteToGoogleStorage.java
/** * This will set empty string when a folder is unshared/Unlinked to the * setting service and storing the setting value in the session for accessing later calls(as Setting service call seems to be buggy sometime). * @throws IOException //from ww w . ja va 2 s .c o m * @throws ServletException * * */ public synchronized static Boolean setUnLinkingToSettingService(TcSessionData tcSessionData, HttpServletRequest request) throws ServletException, IOException { Boolean state = false; TcSiteToGoogleLink result = null; String linkedGoogleFolder = (String) request.getSession() .getAttribute(GoogleLtiServlet.SETTING_SERVICE_VALUE_IN_SESSION); M_log.debug("The value of session in setUnLinkingToSettingService function: " + linkedGoogleFolder); if (linkedGoogleFolder != null) { result = parseLink(linkedGoogleFolder); } state = SettingsClientUtils.setSetting(tcSessionData, ""); if (state) { GoogleCache.getInstance().setLinkForSite(tcSessionData.getContextId(), result); setSettingToSession(request, null); } else { M_log.error("Setting service call is unsuccessful and putting the Settings value in session failed"); } return state; }
From source file:com.yahoo.dba.perf.myperf.springmvc.MyPerfBaseController.java
public static String findUserFromRequest(HttpServletRequest req) { if (req.getUserPrincipal() != null) return req.getUserPrincipal().getName();//find from security login JAAS if (req.getSession() != null) { try {//from w w w. j av a 2s. co m return retrieveAppUser(req).getName();//find from session } catch (Exception ex) { } } return null; }
From source file:com.sifcoapp.report.util.ReportConfigUtil.java
/** * PUBLIC METHODS//w ww .j av a 2s.c o m */ public static boolean compileReport(ServletContext context, String compileDir, String filename) throws JRException { ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); HttpServletRequest request = (HttpServletRequest) externalContext.getRequest(); String jasperFileName = request.getSession().getServletContext().getRealPath("/"); jasperFileName = request.getSession().getServletContext().getRealPath("/reports/compile") + "/" + filename + ".jasper"; //String jasperFileName = context.getRealPath(compileDir + filename + ".jasper"); File jasperFile = new File(jasperFileName); if (jasperFile.exists()) { return true; // jasper file already exists, do not compile again } try { // jasper file has not been constructed yet, so compile the xml file setCompileTempDir(request, compileDir); String xmlFileName = jasperFileName.substring(0, jasperFileName.indexOf(".jasper")) + ".jrxml"; JasperCompileManager.compileReportToFile(xmlFileName); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
From source file:com.adito.policyframework.PolicyUtil.java
/** * Check if a user has a specified permission, throwing an exception if it * doesnt//from w w w.ja v a 2s. c o m * * @param resourceType resource type to check * @param permission permission required * @param request request to extract user object from * @throws NoPermissionException if permission is denied */ public static void checkPermission(ResourceType<?> resourceType, Permission permission, HttpServletRequest request) throws NoPermissionException { checkPermission(resourceType, permission, request.getSession()); }
From source file:gov.nih.nci.evs.browser.servlet.ValueSetServlet.java
public static void create_vs_subtree(HttpServletRequest request, HttpServletResponse response, int view, String dictionary, String version, String vsd_uri) { request.getSession().removeAttribute("b"); request.getSession().removeAttribute("m"); response.setContentType("text/html"); PrintWriter out = null;/*from w w w . j a v a2 s .c om*/ //String checked_vocabularies = HTTPUtils.cleanXSS((String) request.getParameter("checked_vocabularies")); //String partial_checked_vocabularies = HTTPUtils.cleanXSS((String) request.getParameter("partial_checked_vocabularies")); //System.out.println("partial_checked_vocabularies: " + partial_checked_vocabularies); try { out = response.getWriter(); } catch (Exception ex) { ex.printStackTrace(); return; } //String message = (String) request.getSession().getAttribute("message"); try { out.close(); } catch (Exception ex) { ex.printStackTrace(); return; } }
From source file:com.mobileman.projecth.web.controller.InitController.java
private static void initApplication(HttpServletRequest request) { // workaround for OpenSessionInView spring class webApplicationContext = RequestContextUtils.getWebApplicationContext(request); OpenSessionFilter.setWebApplicationContext(webApplicationContext); //load menus/*w w w .j a v a2 s .co m*/ HttpSession session = request.getSession(); session.getServletContext().setAttribute("menu", new Menu(request)); //session timeout seconds session.getServletContext().setAttribute("session_timeout_seconds", session.getMaxInactiveInterval()); }
From source file:edu.cornell.mannlib.vitro.webapp.freemarker.config.FreemarkerConfiguration.java
private static TemplateLoader createTemplateLoader(HttpServletRequest req, String themeDir) { ServletContext ctx = req.getSession().getServletContext(); List<TemplateLoader> loaders = new ArrayList<TemplateLoader>(); // Theme template loader - only if the theme has a template directory. String themeTemplatePath = ctx.getRealPath("/" + themeDir) + "/templates"; File themeTemplateDir = new File(themeTemplatePath); if (themeTemplateDir.exists()) { loaders.add(new FreemarkerTemplateLoader(themeTemplateDir)); }//from ww w. j a v a2 s . com // Vitro template loader String vitroTemplatePath = ctx.getRealPath("/templates/freemarker"); loaders.add(new FreemarkerTemplateLoader(new File(vitroTemplatePath))); // TODO VIVO-243 Why is this here? loaders.add(new ClassTemplateLoader(FreemarkerConfiguration.class, "")); TemplateLoader[] loaderArray = loaders.toArray(new TemplateLoader[loaders.size()]); TemplateLoader tl = new MultiTemplateLoader(loaderArray); // If requested, add delimiters to the templates. DeveloperSettings settings = DeveloperSettings.getInstance(); if (settings.getBoolean(Key.INSERT_FREEMARKER_DELIMITERS)) { tl = new DelimitingTemplateLoader(tl); } return tl; }
From source file:eionet.gdem.web.struts.stylesheet.StylesheetListLoader.java
private static StylesheetListHolder loadStylesheetGeneratedList(HttpServletRequest httpServletRequest, boolean reload) throws DCMException { Object st = httpServletRequest.getSession().getServletContext() .getAttribute(STYLESHEET_GENERATED_LIST_ATTR); if (st == null || !(st instanceof StylesheetListHolder) || reload || generatedListIsExpired()) { st = new StylesheetListHolder(); try {// w w w. j av a2 s. c o m SchemaManager sm = new SchemaManager(); st = sm.getSchemas("generated"); } catch (DCMException e) { e.printStackTrace(); LOGGER.error("Error getting stylesheet generated list", e); throw e; } httpServletRequest.getSession().getServletContext().setAttribute(STYLESHEET_GENERATED_LIST_ATTR, st); } Object permissions = httpServletRequest.getSession().getAttribute(STYLESHEET_PERMISSIONS_ATTR); if (permissions == null || !(permissions instanceof QAScriptListHolder)) { loadPermissions(httpServletRequest); } return (StylesheetListHolder) st; }
From source file:eionet.gdem.web.struts.stylesheet.StylesheetListLoader.java
private static List<Schema> loadConversionSchemasList(HttpServletRequest httpServletRequest, boolean reload) throws DCMException { Object schemas = httpServletRequest.getSession().getServletContext().getAttribute(CONVERSION_SCHEMAS_ATTR); if (schemas == null || !(schemas instanceof List) || reload) { schemas = new ArrayList<Schema>(); try {//from ww w . j a va2 s.c o m SchemaManager sm = new SchemaManager(); schemas = sm.getSchemas(); } catch (DCMException e) { e.printStackTrace(); LOGGER.error("Error getting schemas list", e); throw e; } httpServletRequest.getSession().getServletContext().setAttribute(CONVERSION_SCHEMAS_ATTR, schemas); } return (List<Schema>) schemas; }
From source file:eionet.gdem.web.struts.stylesheet.StylesheetListLoader.java
/** * Load stylesheets info and permissions store it in the context. * @param httpServletRequest/*www . j a va2s.c om*/ * @param reload * @return * @throws DCMException */ private static StylesheetListHolder loadStylesheetList(HttpServletRequest httpServletRequest, boolean reload) throws DCMException { Object holder = httpServletRequest.getSession().getServletContext().getAttribute(STYLESHEET_LIST_ATTR); if (holder == null || !(holder instanceof StylesheetListHolder) || reload) { StylesheetListHolder stylesheetsHolder = new StylesheetListHolder(); try { StylesheetManager stylesheetManager = new StylesheetManager(); List<Stylesheet> stylesheets = stylesheetManager.getStylesheets(); stylesheetsHolder.setStylesheetList(stylesheets); holder = stylesheetsHolder; } catch (DCMException e) { e.printStackTrace(); LOGGER.error("Error getting stylesheet list", e); throw e; } httpServletRequest.getSession().getServletContext().setAttribute(STYLESHEET_LIST_ATTR, stylesheetsHolder); } Object permissions = httpServletRequest.getSession().getServletContext() .getAttribute(STYLESHEET_PERMISSIONS_ATTR); if (permissions == null || !(permissions instanceof QAScriptListHolder)) { loadPermissions(httpServletRequest); } return (StylesheetListHolder) holder; }