List of usage examples for javax.servlet.http HttpServletRequest removeAttribute
public void removeAttribute(String name);
From source file:com.opencnc.controllers.RolController.java
/** * ***************************************************************************** * Borra Rol// ww w.j av a2 s . c om * ***************************************************************************** * @param id * @param request * @param response * @return * @throws Exception */ @RequestMapping("/rol/borrarRol/{id}") public ModelAndView borrarRol(@PathVariable Integer id, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession sess = request.getSession(); if (sess != null) { Session s = HibernateUtil.getSessionFactory().openSession(); Rol r = (Rol) s.get(Rol.class, id); Transaction t = s.beginTransaction(); s.delete(r); t.commit(); return lista(request, response); } else { request.removeAttribute("usuario"); return new ModelAndView("redirect:/usuario/login.htm"); } }
From source file:org.terasoluna.gfw.web.logging.TraceLoggingInterceptor.java
/** * Logic to output end log// w ww.j av a 2 s . c o m * <p> * Outputs the end log.<br> * Outputs warning log if difference of time between start time and end time is more than the nano-seconds value<br> * set as warning log output timing. * </p> * @see org.springframework.web.servlet.handler.HandlerInterceptorAdapter#postHandle(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.web.servlet.ModelAndView) */ @Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) { if (!(handler instanceof HandlerMethod)) { return; } long startTime = 0; if (request.getAttribute(START_ATTR) != null) { startTime = ((Long) request.getAttribute(START_ATTR)).longValue(); } long handlingTime = System.nanoTime() - startTime; request.removeAttribute(START_ATTR); request.setAttribute(HANDLING_ATTR, handlingTime); String formattedHandlingTime = String.format("%1$,3d", handlingTime); boolean isWarnHandling = handlingTime > warnHandlingNanos; if (!isEnabledLogLevel(isWarnHandling)) { return; } HandlerMethod handlerMethod = (HandlerMethod) handler; Method m = handlerMethod.getMethod(); Object view = null; Map<String, Object> model = null; if (modelAndView != null) { view = modelAndView.getView(); model = modelAndView.getModel(); if (view == null) { view = modelAndView.getViewName(); } } logger.trace("[END CONTROLLER ] {}.{}({})-> view={}, model={}", new Object[] { m.getDeclaringClass().getSimpleName(), m.getName(), buildMethodParams(handlerMethod), view, model }); String handlingTimeMessage = "[HANDLING TIME ] {}.{}({})-> {} ns"; if (isWarnHandling) { logger.warn(handlingTimeMessage + " > {}", new Object[] { m.getDeclaringClass().getSimpleName(), m.getName(), buildMethodParams(handlerMethod), formattedHandlingTime, warnHandlingNanos }); } else { logger.trace(handlingTimeMessage, new Object[] { m.getDeclaringClass().getSimpleName(), m.getName(), buildMethodParams(handlerMethod), formattedHandlingTime }); } }
From source file:com.opencnc.controllers.ProgramaController.java
/** ******************************************************************************* * Borra los programas de CAD de cualquier usuario. * ***************************************************************************** * @param id// ww w . j av a 2s . c o m * @param request * @param response * @return * @throws Exception */ @RequestMapping("/programa/borrar/{id}") public ModelAndView borrar(@PathVariable Integer id, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession sess = request.getSession(); if (sess != null) { Session s = HibernateUtil.getSessionFactory().openSession(); Programa e = (Programa) s.get(Programa.class, id); Transaction t = s.beginTransaction(); s.delete(e); t.commit(); return lista(request, response); } else { request.removeAttribute("usuario"); return new ModelAndView("redirect:/usuario/login.htm"); } }
From source file:com.glaf.report.web.springmvc.MxReportController.java
@RequestMapping("/chooseQuery") public ModelAndView chooseQuery(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Map<String, Object> params = RequestUtils.getParameterMap(request); String rowId = ParamUtils.getString(params, "reportId"); QueryDefinitionQuery query = new QueryDefinitionQuery(); List<QueryDefinition> list = queryDefinitionService.list(query); request.setAttribute("unselecteds", list); Report report = null;/*from w w w . j a v a 2 s . c om*/ if (StringUtils.isNotEmpty(rowId)) { report = reportService.getReport(rowId); request.setAttribute("report", report); if (StringUtils.isNotEmpty(report.getQueryIds())) { StringBuffer sb01 = new StringBuffer(); StringBuffer sb02 = new StringBuffer(); List<String> selecteds = new java.util.ArrayList<String>(); for (QueryDefinition q : list) { if (StringUtils.contains(report.getQueryIds(), q.getId())) { selecteds.add(q.getId()); sb01.append(q.getId()).append(","); sb02.append(q.getName()).append(","); } } if (sb01.toString().endsWith(",")) { sb01.delete(sb01.length() - 1, sb01.length()); } if (sb02.toString().endsWith(",")) { sb02.delete(sb02.length() - 1, sb02.length()); } request.setAttribute("selecteds", selecteds); request.setAttribute("queryIds", sb01.toString()); request.setAttribute("queryNames", sb02.toString()); } } String x_view = ViewProperties.getString("report.chooseQuery"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/bi/report/chooseQuery", modelMap); }
From source file:com.opencnc.controllers.ProgramaController.java
/** * ***************************************************************************** * Actualiza los atributos en la base de datos de los programas. * ***************************************************************************** * @param p/*from www. j a v a 2 s. c o m*/ * @param request * @param response * @return * @throws Exception */ @RequestMapping("/programa/actualizar") public ModelAndView actualizar(@ModelAttribute Programa p, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession sess = request.getSession(); if (sess != null) { Session s = HibernateUtil.getSessionFactory().openSession(); p.setDescripcion("Nombre"); Transaction t = s.getTransaction(); s.beginTransaction(); s.saveOrUpdate(p); t.commit(); return lista(request, response); } else { request.removeAttribute("usuario"); return new ModelAndView("redirect:/usuario/login.htm"); } }
From source file:org.apache.struts.faces.application.FacesRequestProcessor.java
/** * <p>Set up a Faces Request if we are not already processing one. Next, * create a new view if the specified <code>uri</code> is different from * the current view identifier. Finally, cause the new view to be * rendered, and call <code>FacesContext.responseComplete()</code> to * indicate that this has already been done.</p> * * @param uri Context-relative path to forward to * @param request Current page request/* ww w . ja va 2 s . com*/ * @param response Current page response * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet error occurs */ protected void doForward(String uri, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (log.isDebugEnabled()) { log.debug("doForward(" + uri + ")"); } // Remove the current ActionEvent (if any) request.removeAttribute(Constants.ACTION_EVENT_KEY); // Process a Struts controller request normally if (isStrutsRequest(uri)) { if (response.isCommitted()) { if (log.isTraceEnabled()) { log.trace(" super.doInclude(" + uri + ")"); } super.doInclude(uri, request, response); } else { if (log.isTraceEnabled()) { log.trace(" super.doForward(" + uri + ")"); } super.doForward(uri, request, response); } return; } // Create a FacesContext for this request if necessary LifecycleFactory lf = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); Lifecycle lifecycle = // FIXME - alternative lifecycle ids lf.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE); boolean created = false; FacesContext context = FacesContext.getCurrentInstance(); if (context == null) { if (log.isTraceEnabled()) { log.trace(" Creating new FacesContext for '" + uri + "'"); } created = true; FacesContextFactory fcf = (FacesContextFactory) FactoryFinder .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); // HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(request, uri); // context = fcf.getFacesContext(servlet.getServletContext(), wrapper, // response, lifecycle); // Comment out the previous three lines and uncomment // the following two lines to test eliminating the wrapper context = fcf.getFacesContext(servlet.getServletContext(), request, response, lifecycle); } // Create a new view root ViewHandler vh = context.getApplication().getViewHandler(); if (log.isTraceEnabled()) { log.trace(" Creating new view for '" + uri + "'"); } context.setViewRoot(vh.createView(context, uri)); // Cause the view to be rendered if (log.isTraceEnabled()) { log.trace(" Rendering view for '" + uri + "'"); } lifecycle.render(context); if (created) { if (log.isTraceEnabled()) { log.trace(" Releasing context for '" + uri + "'"); } context.release(); } else { if (log.isTraceEnabled()) { log.trace(" Rendering completed"); } } }
From source file:org.apache.struts.faces.application.FacesTilesRequestProcessor.java
/** * <p>Set up a Faces Request if we are not already processing one. Next, * create a new view if the specified <code>uri</code> is different from * the current view identifier. Finally, cause the new view to be * rendered, and call <code>FacesContext.responseComplete()</code> to * indicate that this has already been done.</p> * * @param uri Context-relative path to forward to * @param request Current page request//from ww w . j av a2s. co m * @param response Current page response * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet error occurs */ protected void doForward(String uri, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (log.isDebugEnabled()) { log.debug("doForward(" + uri + ")"); } // Remove the current ActionEvent (if any) request.removeAttribute(Constants.ACTION_EVENT_KEY); // Process a Struts controller request normally if (isStrutsRequest(uri)) { if (response.isCommitted()) { if (log.isTraceEnabled()) { log.trace(" super.doInclude(" + uri + ")"); } super.doInclude(uri, request, response); } else { if (log.isTraceEnabled()) { log.trace(" super.doForward(" + uri + ")"); } super.doForward(uri, request, response); } return; } // Create a FacesContext for this request if necessary LifecycleFactory lf = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); Lifecycle lifecycle = // FIXME - alternative lifecycle ids lf.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE); boolean created = false; FacesContext context = FacesContext.getCurrentInstance(); if (context == null) { if (log.isTraceEnabled()) { log.trace(" Creating new FacesContext for '" + uri + "'"); } created = true; FacesContextFactory fcf = (FacesContextFactory) FactoryFinder .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(request, uri); context = fcf.getFacesContext(servlet.getServletContext(), wrapper, response, lifecycle); // Comment out the previous three lines and uncomment // the following two lines to test eliminating the wrapper // context = fcf.getFacesContext(servlet.getServletContext(), // request, response, lifecycle); } // Create a new view root ViewHandler vh = context.getApplication().getViewHandler(); if (log.isTraceEnabled()) { log.trace(" Creating new view for '" + uri + "'"); } context.setViewRoot(vh.createView(context, uri)); // Cause the view to be rendered if (log.isTraceEnabled()) { log.trace(" Rendering view for '" + uri + "'"); } lifecycle.render(context); if (created) { if (log.isTraceEnabled()) { log.trace(" Releasing context for '" + uri + "'"); } context.release(); } else { if (log.isTraceEnabled()) { log.trace(" Rendering completed"); } } }
From source file:com.glaf.report.web.springmvc.MxReportController.java
@RequestMapping("/chooseChart") public ModelAndView chooseChart(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Map<String, Object> params = RequestUtils.getParameterMap(request); String rowId = ParamUtils.getString(params, "reportId"); ChartQuery query = new ChartQuery(); List<Chart> list = chartService.list(query); request.setAttribute("unselecteds", list); Report report = null;/*from ww w .j a va 2 s.c o m*/ if (StringUtils.isNotEmpty(rowId)) { report = reportService.getReport(rowId); request.setAttribute("report", report); if (StringUtils.isNotEmpty(report.getChartIds())) { StringBuffer sb01 = new StringBuffer(); StringBuffer sb02 = new StringBuffer(); List<String> selecteds = new java.util.ArrayList<String>(); List<String> chartIds = StringTools.split(report.getChartIds()); for (Chart c : list) { if (chartIds.contains(c.getId())) { selecteds.add(c.getId()); sb01.append(c.getId()).append(","); sb02.append(c.getSubject()).append(","); } } if (sb01.toString().endsWith(",")) { sb01.delete(sb01.length() - 1, sb01.length()); } if (sb02.toString().endsWith(",")) { sb02.delete(sb02.length() - 1, sb02.length()); } request.setAttribute("selecteds", selecteds); request.setAttribute("chartIds", sb01.toString()); request.setAttribute("chartNames", sb02.toString()); } if (StringUtils.isNotEmpty(report.getQueryIds())) { List<String> queryIds = StringTools.split(report.getQueryIds()); StringBuffer sb01 = new StringBuffer(); StringBuffer sb02 = new StringBuffer(); for (String queryId : queryIds) { QueryDefinition queryDefinition = queryDefinitionService.getQueryDefinition(queryId); if (queryDefinition != null) { sb01.append(queryDefinition.getId()).append(","); sb02.append(queryDefinition.getTitle()).append("[").append(queryDefinition.getId()) .append("],"); } } if (sb01.toString().endsWith(",")) { sb01.delete(sb01.length() - 1, sb01.length()); } if (sb02.toString().endsWith(",")) { sb02.delete(sb02.length() - 1, sb02.length()); } request.setAttribute("queryIds", sb01.toString()); request.setAttribute("queryNames", sb02.toString()); } } String x_view = ViewProperties.getString("report.chooseChart"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/bi/report/chooseChart", modelMap); }
From source file:com.glaf.report.web.springmvc.MxReportController.java
@RequestMapping("/edit") public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Map<String, Object> params = RequestUtils.getParameterMap(request); String reportId = ParamUtils.getString(params, "reportId"); Report report = null;/*from w ww . ja v a 2 s .c o m*/ if (StringUtils.isNotEmpty(reportId)) { report = reportService.getReport(reportId); request.setAttribute("report", report); if (StringUtils.isNotEmpty(report.getChartIds())) { StringBuffer sb01 = new StringBuffer(); StringBuffer sb02 = new StringBuffer(); List<Chart> selecteds = new java.util.ArrayList<Chart>(); ChartQuery query = new ChartQuery(); List<Chart> list = chartService.list(query); request.setAttribute("unselecteds", list); List<String> selected = StringTools.split(report.getChartIds()); for (Chart c : list) { if (selected.contains(c.getId())) { selecteds.add(c); sb01.append(c.getId()).append(","); sb02.append(c.getSubject()).append(","); } } if (sb01.toString().endsWith(",")) { sb01.delete(sb01.length() - 1, sb01.length()); } if (sb02.toString().endsWith(",")) { sb02.delete(sb02.length() - 1, sb02.length()); } request.setAttribute("selecteds", selecteds); request.setAttribute("chartIds", sb01.toString()); request.setAttribute("chartNames", sb02.toString()); } if (StringUtils.isNotEmpty(report.getQueryIds())) { List<String> queryIds = StringTools.split(report.getQueryIds()); StringBuffer sb01 = new StringBuffer(); StringBuffer sb02 = new StringBuffer(); for (String queryId : queryIds) { QueryDefinition queryDefinition = queryDefinitionService.getQueryDefinition(queryId); if (queryDefinition != null) { sb01.append(queryDefinition.getId()).append(","); sb02.append(queryDefinition.getTitle()).append("[").append(queryDefinition.getId()) .append("],"); } } if (sb01.toString().endsWith(",")) { sb01.delete(sb01.length() - 1, sb01.length()); } if (sb02.toString().endsWith(",")) { sb02.delete(sb02.length() - 1, sb02.length()); } request.setAttribute("queryIds", sb01.toString()); request.setAttribute("queryNames", sb02.toString()); } } String view = request.getParameter("view"); if (StringUtils.isNotEmpty(view)) { return new ModelAndView(view, modelMap); } String x_view = ViewProperties.getString("report.edit"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/bi/report/edit", modelMap); }
From source file:com.opencnc.controllers.ElementoGraficoController.java
/** * ***************************************************************************** * Obtiene los Elementos graficos de la base de datos. * ***************************************************************************** * Metodo sin desarrollo.//from ww w. jav a 2s . c o m * ***************************************************************************** * @param id * @param request * @param response * @return * @throws Exception */ @RequestMapping("/elemento/obtenerElemento") public ModelAndView obtenerElemento(@PathVariable Integer id, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession sess = request.getSession(); if (sess != null) { return null; } else { request.removeAttribute("usuario"); return new ModelAndView("redirect:/usuario/login.htm"); } }