List of usage examples for javax.servlet.http HttpSession getServletContext
public ServletContext getServletContext();
From source file:org.hdiv.web.servlet.tags.form.AbstractHtmlElementTagTests.java
protected void initDataComposer() { String[] files = { "/org/hdiv/config/hdiv-core-applicationContext.xml", "/hdiv-config.xml", "/hdiv-validations.xml", }; if (this.hdivContext == null) { this.hdivContext = new ClassPathXmlApplicationContext(files); }/*from ww w . j a va 2s . c o m*/ //API mock de Servlet // HttpServletRequest request = (MockHttpServletRequest) this.hdivContext.getBean("mockRequest"); MockHttpServletRequest request = (MockHttpServletRequest) pageContext.getRequest(); HttpSession httpSession = request.getSession(); ServletContext servletContext = httpSession.getServletContext(); HDIVUtil.setHttpServletRequest(request); //inicializar StateCache en session this.initStateCache(httpSession); //inicializar HDIVConfig en ServletContext HDIVConfig hdivConfig = (HDIVConfig) this.hdivContext.getBean("config"); HDIVUtil.setHDIVConfig(hdivConfig, servletContext); //inicializar IApplication en ServletContext IApplication application = (IApplication) this.hdivContext.getBean("application"); HDIVUtil.setApplication(application, servletContext); //inicializar MessageSource en ServletContext MessageSource messageSource = (MessageSource) this.hdivContext; HDIVUtil.setMessageSource(messageSource, servletContext); //inicializar el datacomposer DataComposerFactory dataComposerFactory = (DataComposerFactory) this.hdivContext .getBean("dataComposerFactory"); IDataComposer dataComposer = dataComposerFactory.newInstance(); dataComposer.beginRequest("/testFormTag.do"); HDIVUtil.setDataComposer(dataComposer, request); }
From source file:org.wso2.carbon.identity.authenticator.iwa.ui.IWAUIAuthenticator.java
/** * @param request/* ww w .j a v a2 s . c om*/ * @return * @throws AxisFault */ private IWAAuthenticatorStub getIWAClient(HttpServletRequest request) throws AxisFault, IdentityException { HttpSession session = request.getSession(); ServletContext servletContext = session.getServletContext(); String backendServerURL = request.getParameter("backendURL"); if (backendServerURL == null) { backendServerURL = CarbonUIUtil.getServerURL(servletContext, request.getSession()); } ConfigurationContext configContext = (ConfigurationContext) servletContext .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); String serviceEPR = backendServerURL + "IWAAuthenticator"; IWAAuthenticatorStub stub = new IWAAuthenticatorStub(configContext, serviceEPR); ServiceClient client = stub._getServiceClient(); client.engageModule("rampart"); Policy rampartConfig = IdentityBaseUtil.getDefaultRampartConfig(); Policy signOnly = IdentityBaseUtil.getSignOnlyPolicy(); Policy mergedPolicy = signOnly.merge(rampartConfig); Options options = client.getOptions(); options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, mergedPolicy); options.setManageSession(true); return stub; }
From source file:org.wso2.carbon.identity.authenticator.webseal.ui.WebSealUIAuthenticator.java
@Override public void unauthenticate(Object o) throws Exception { HttpServletRequest request = (HttpServletRequest) o; HttpSession session = request.getSession(); ServletContext servletContext = session.getServletContext(); ConfigurationContext configContext = (ConfigurationContext) servletContext .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); String backendServerURL = CarbonUIUtil.getServerURL(servletContext, session); try {//from w ww . ja v a 2 s . c om String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_AUTH_TOKEN); WebSealAuthenticatorClient client = new WebSealAuthenticatorClient(configContext, backendServerURL, cookie, session); client.logout(session); } catch (AuthenticationException e) { String msg = "Error occurred while logging out"; log.error(msg, e); throw new Exception(msg, e); } }
From source file:org.intermine.bio.webservice.GFFQueryService.java
@Override protected void execute() throws Exception { HttpSession session = request.getSession(); ServletContext servletContext = session.getServletContext(); // get the project title to be written in GFF3 records Properties props = (Properties) servletContext.getAttribute(Constants.WEB_PROPERTIES); String sourceName = props.getProperty("project.title"); Set<Integer> organisms = null; PathQuery pathQuery = getQuery();/*from w w w . j a va 2s . c om*/ Exporter exporter; try { List<Integer> indexes = new ArrayList<Integer>(); List<String> viewColumns = new ArrayList<String>(pathQuery.getView()); for (int i = 0; i < viewColumns.size(); i++) { indexes.add(Integer.valueOf(i)); } removeFirstItemInPaths(viewColumns); exporter = new GFF3Exporter(pw, indexes, getSoClassNames(servletContext), viewColumns, sourceName, organisms, false); ExportResultsIterator iter = null; try { Profile profile = SessionMethods.getProfile(session); PathQueryExecutor executor = this.im.getPathQueryExecutor(profile); iter = executor.execute(pathQuery, 0, WebServiceRequestParser.DEFAULT_MAX_COUNT); iter.goFaster(); exporter.export(iter); } finally { if (iter != null) { iter.releaseGoFaster(); } } } catch (Exception e) { throw new InternalErrorException("Service failed:" + e, e); } }
From source file:org.intermine.web.struts.ObjectViewController.java
/** * {@inheritDoc}/* w w w. jav a 2 s . c o m*/ */ @Override public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession session = request.getSession(); final InterMineAPI im = SessionMethods.getInterMineAPI(session); ObjectStore os = im.getObjectStore(); final WebConfig webConfig = SessionMethods.getWebConfig(session.getServletContext()); String idString = (String) context.getAttribute("id"); // not a key field if (StringUtils.isEmpty(idString)) { return null; } String fieldName = (String) context.getAttribute("fieldName"); fieldName = fieldName.trim(); Integer id = new Integer(Integer.parseInt(idString)); InterMineObject object = os.getObjectById(id); if (object == null) { return null; } String clsName = DynamicUtil.getSimpleClass(object).getName(); FieldConfig fc = webConfig.getFieldConfig(clsName, fieldName); // truncate fields by default, unless it says otherwise in config // escape xml/html by default, unless it says otherwise in config boolean doNotTruncate = false; boolean escapeXml = true; if (fc != null) { doNotTruncate = fc.getDoNotTruncate(); escapeXml = fc.getEscapeXml(); } request.setAttribute("doNotTruncate", Boolean.valueOf(doNotTruncate)); request.setAttribute("escapeXml", Boolean.valueOf(escapeXml)); request.setAttribute("fieldName", fieldName); return null; }
From source file:com.crimelab.service.MedicoLegalServiceImpl.java
@Override public Workbook create(MedicoLegal medicoLegal, HttpSession session) { Workbook wb = null;/* ww w . j av a 2 s . c om*/ try { InputStream inp = session.getServletContext().getResourceAsStream("/WEB-INF/templates/Default.xls"); wb = WorkbookFactory.create(inp); Sheet sheet = wb.getSheetAt(0); Cell division = findCell(sheet, "$division"); Cell reportNo = findCell(sheet, "$reportNo"); Cell caseType = findCell(sheet, "$caseType"); Cell suspect = findCell(sheet, "$suspect"); Cell victim = findCell(sheet, "$victim"); Cell timeDateReceived = findCell(sheet, "$timeDateReceived"); Cell requestingParty = findCell(sheet, "$requestingParty"); Cell specimenSubmitted = findCell(sheet, "$specimenSubmitted"); Cell purposeOfLabExam = findCell(sheet, "$purposeOfLabExam"); Cell findings = findCell(sheet, "$findings"); Cell conclusion = findCell(sheet, "$conclusion"); Cell remarks = findCell(sheet, "$remarks"); Cell timeDateCompleted = findCell(sheet, "$timeDateCompleted"); Cell examinerName = findCell(sheet, "$examinerName"); Cell examinerRank = findCell(sheet, "$examinerRank"); Cell examinerPosition = findCell(sheet, "$examinerPosition"); Cell notedName = findCell(sheet, "$notedName"); Cell notedRank = findCell(sheet, "$notedRank"); Cell notedPosition = findCell(sheet, "$notedPosition"); division.setCellValue(medicoLegal.getDivision()); reportNo.setCellValue(medicoLegal.getReportNo()); caseType.setCellValue(medicoLegal.getCaseType()); suspect.setCellValue(medicoLegal.getSuspect()); victim.setCellValue(medicoLegal.getVictim()); timeDateReceived.setCellValue(medicoLegal.getTimeDateReceived()); requestingParty.setCellValue(medicoLegal.getRequestingParty()); specimenSubmitted.setCellValue(medicoLegal.getSpecimenSubmitted()); purposeOfLabExam.setCellValue(medicoLegal.getPurposeOfLabExam()); findings.setCellValue(medicoLegal.getFindings()); conclusion.setCellValue(medicoLegal.getConclusion()); remarks.setCellValue(medicoLegal.getRemarks()); timeDateCompleted.setCellValue(medicoLegal.getTimeDateCompleted()); examinerName.setCellValue(medicoLegal.getExaminerName()); examinerRank.setCellValue(medicoLegal.getExaminerRank()); examinerPosition.setCellValue(medicoLegal.getExaminerPosition()); notedName.setCellValue(medicoLegal.getNotedName()); notedRank.setCellValue(medicoLegal.getNotedRank()); notedPosition.setCellValue(medicoLegal.getNotedPosition()); medicoLegalDAO.medicoLegalInfo(medicoLegal); } catch (Exception e) { e.printStackTrace(); } return wb; }
From source file:uk.ac.ebi.ep.controller.BrowsePathwaysController.java
private String computeResult(@ModelAttribute("searchModel") SearchModel searchModel, @RequestParam(value = "entryid", required = false) String entryID, @RequestParam(value = "entryname", required = false) String entryName, Model model, HttpSession session, HttpServletRequest request) {/* w ww . j ava2s . c o m*/ String view = "error"; Map<String, SearchResults> prevSearches = getPreviousSearches(session.getServletContext()); String searchKey = getSearchKey(searchModel.getSearchparams()); SearchResults results = prevSearches.get(searchKey); if (results == null) { // New search: clearHistory(session); results = findEnzymesByPathway(entryID, entryName); } if (results != null) { cacheSearch(session.getServletContext(), searchKey, results); setLastSummaries(session, results.getSummaryentries()); searchModel.setSearchresults(results); applyFilters(searchModel, request); model.addAttribute("searchConfig", searchConfig); model.addAttribute("searchModel", searchModel); model.addAttribute("pagination", getPagination(searchModel)); clearHistory(session); addToHistory(session, searchModel.getSearchparams().getType(), searchKey); view = RESULT; } return view; }
From source file:com.crimelab.service.FirearmsServiceImpl.java
@Override public Workbook create(Firearms firearms, HttpSession session) { Workbook wb = null;/*from www. jav a2 s. c o m*/ try { InputStream inp = session.getServletContext().getResourceAsStream("/WEB-INF/templates/Default.xls"); wb = WorkbookFactory.create(inp); Sheet sheet = wb.getSheetAt(0); Cell division = findCell(sheet, "$division"); Cell reportNo = findCell(sheet, "$reportNo"); Cell caseType = findCell(sheet, "$caseType"); Cell suspect = findCell(sheet, "$suspect"); Cell victim = findCell(sheet, "$victim"); Cell timeDateReceived = findCell(sheet, "$timeDateReceived"); Cell requestingParty = findCell(sheet, "$requestingParty"); Cell specimenSubmitted = findCell(sheet, "$specimenSubmitted"); Cell purposeOfLabExam = findCell(sheet, "$purposeOfLabExam"); Cell findings = findCell(sheet, "$findings"); Cell conclusion = findCell(sheet, "$conclusion"); Cell remarks = findCell(sheet, "$remarks"); Cell timeDateCompleted = findCell(sheet, "$timeDateCompleted"); Cell examinerName = findCell(sheet, "$examinerName"); Cell examinerRank = findCell(sheet, "$examinerRank"); Cell examinerPosition = findCell(sheet, "$examinerPosition"); Cell notedName = findCell(sheet, "$notedName"); Cell notedRank = findCell(sheet, "$notedRank"); Cell notedPosition = findCell(sheet, "$notedPosition"); division.setCellValue(firearms.getDivision()); reportNo.setCellValue(firearms.getReportNo()); caseType.setCellValue(firearms.getCaseType()); suspect.setCellValue(firearms.getSuspect()); victim.setCellValue(firearms.getVictim()); timeDateReceived.setCellValue(firearms.getTimeDateReceived()); requestingParty.setCellValue(firearms.getRequestingParty()); specimenSubmitted.setCellValue(firearms.getSpecimenSubmitted()); purposeOfLabExam.setCellValue(firearms.getPurposeOfLabExam()); findings.setCellValue(firearms.getFindings()); conclusion.setCellValue(firearms.getConclusion()); remarks.setCellValue(firearms.getRemarks()); timeDateCompleted.setCellValue(firearms.getTimeDateCompleted()); examinerName.setCellValue(firearms.getExaminerName()); examinerRank.setCellValue(firearms.getExaminerRank()); examinerPosition.setCellValue(firearms.getExaminerPosition()); notedName.setCellValue(firearms.getNotedName()); notedRank.setCellValue(firearms.getNotedRank()); notedPosition.setCellValue(firearms.getNotedPosition()); firearmsDAO.firearmsInfo(firearms); } catch (Exception e) { e.printStackTrace(); } return wb; }
From source file:com.mobileman.projecth.web.controller.ExportController.java
@RequestMapping(method = RequestMethod.GET, value = "/customer/{page}") public String getPage(HttpSession session, HttpServletRequest request, @PathVariable String page) { return processPage(session.getServletContext(), page); }