Java Code Examples for javax.servlet.http.HttpSession.getAttribute()

The following are Jave code examples for showing how to use getAttribute() of the javax.servlet.http.HttpSession class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: lams   File: LearningAction.java   View Source Code Vote up 6 votes
private AssessmentUser getCurrentUser(Long sessionId) {
IAssessmentService service = getAssessmentService();

// try to get form system session
HttpSession ss = SessionManager.getSession();
// get back login user DTO
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
AssessmentUser assessmentUser = service.getUserByIDAndSession(new Long(user.getUserID().intValue()), sessionId);

if (assessmentUser == null) {
    AssessmentSession session = service.getAssessmentSessionBySessionId(sessionId);
    assessmentUser = new AssessmentUser(user, session);
    service.createUser(assessmentUser);
}
return assessmentUser;
   }
 
Example 2
Project: timesheet-upload   File: RegistrationController.java   View Source Code Vote up 6 votes
@GetMapping("/viewProfile")
public ModelAndView viewProfile(HttpSession session, Model model) {
    log.info("Inside viewProfile method of Registration Controller.");
    Employee employee = (Employee) session.getAttribute("user");
    //Check if the employee object exist in the session.
    if (employee == null) {
        log.error("Cannot find employee object in the session, so forwarding to Login page");
        model.addAttribute("css", "danger");
        model.addAttribute("msg", "Your session expired, please login to continue!!");
        return new ModelAndView("redirect:/login");
    }
    model.addAttribute("employee", employee);
    if (employee.isEmployeeRole()) {
        return new ModelAndView("employee/viewProfile");
    } else if (employee.isSupervisorRole()) {
        return new ModelAndView("staff/viewProfileStaff");
    } else if (employee.isAdminRole()) {
        return new ModelAndView("staff/viewProfileStaff");
    } else {
        log.error("Cannot validate the role. Redirecting to the Login page.");
        model.addAttribute("css", "danger");
        model.addAttribute("msg", "Cannot validate the role, please login to continue!!");
        return new ModelAndView("redirect:/login");
    }

}
 
Example 3
Project: OMIPlatform   File: EducationController.java   View Source Code Vote up 6 votes
/**
 * 教育官网首页
 */
@GetMapping("/home")
public String home(Model model, HttpServletRequest request, HttpSession session) {
    Integer newpv = (Integer) session.getAttribute("is_new");
    if (newpv == null) {
        try {
            TzPv pv = new TzPv();
            pv.setUserip(Utils.getIpAddress(request));
            pv.setUseragent(request.getHeader("User-Agent"));
            pv.setVisittime(new Timestamp(System.currentTimeMillis()));
            pv.setModule(2);
            this.tzPvService.insert(pv);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        session.setAttribute("is_new", 1);
    }
    model.addAttribute("type", 1);
    return "edu_index";
}
 
Example 4
Project: zhkuas_ssm_maven   File: BaseClassDataController.java   View Source Code Vote up 6 votes
/**
 * 最后一步,保存数据
 * 
 * @param session
 * @return
 */
@ResponseBody
@RequestMapping(value="/classes",method =RequestMethod.POST)
public Map<String, Object> save(HttpSession session) {
	List<BaseClass> list = (List<BaseClass>) session.getAttribute(SessionKey.FETCH_MAJOR_BASECLASS_DATA_LIST.toString());
	int addCount = 0;
	int existCount = 0;
	// 写入数据库
	for (BaseClass bc : list) {
		try {
			baseClassService.addBaseClass(bc);
			addCount++;
		} catch (ObjectExistsException e) {
			existCount++;
		}
	}
	Map<String, Integer> result = new HashMap<String, Integer>();
	result.put("addCount", addCount);
	result.put("existCount", existCount);
	return WebUtils.webJsonResult(result);
}
 
Example 5
Project: SAPNetworkMonitor   File: NiPingAuthFilter.java   View Source Code Vote up 5 votes
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
    final HttpSession session = httpServletRequest.getSession(false);
    if (null == session || null == session.getAttribute(attributeName)) {
        requestContext.abortWith(Response.seeOther(URI.create("/")).build());
    }
}
 
Example 6
Project: school-website   File: HomeworkController.java   View Source Code Vote up 5 votes
@ResponseBody
@RequestMapping("/arrangement")
public CommonResult arrangement(MultipartFile multipartFile, Homework homework, HttpSession session) {
    if (multipartFile == null)
        return new CommonResult("文件为空", false);
    else if (homework.getCourseClassId() == null)
        return new CommonResult("班级为空", false);
    else if (!FileFormatUtils.isPackage(multipartFile.getOriginalFilename()))
        return new CommonResult("文件格式不是压缩包", false);
    else if (multipartFile.getSize() > FILE_SIZE)
        return new CommonResult("文件大小超出限制", false);
    else if (StringUtils.isEmpty(homework.getHomeworkName(), homework.getContent()))
        return new CommonResult("作业名称或正文不能为空", false);
    else {
        if (homework.getHomeworkName().length() > TITLE_SIZE) {
            if (homework.getContent().length() > CONTENT_SIZE)
                return new CommonResult("作业名称和正文太长", false);
            else
                return new CommonResult("作业名称太长", false);
        } else if (homework.getContent().length() > CONTENT_SIZE)
            return new CommonResult("正文太长", false);
    }

    User user = (User)session.getAttribute("user");
    homework.setAnnouncerId(user.getId());
    if (homeworkService.arrangement(homework, multipartFile)) {
        return new CommonResult("成功", true);
    } else
        return new CommonResult("添加作业失败", false);
}
 
Example 7
Project: Projeto_Integrador_3_Semestre   File: CadastroHotelServlet.java   View Source Code Vote up 5 votes
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    HotelService service = new HotelService();
    HotelDAO dao = new HotelDAO();

    RelatorioDAO relatorioDAO = new RelatorioDAO();
    RelatorioMudancas relatorio = new RelatorioMudancas();

    String nome_hotel = request.getParameter("nome_hotel");
    String data_entrada = request.getParameter("data_entrada");
    String data_saida = request.getParameter("data_saida");
    int quantidade_quartos = Integer.parseInt(request.getParameter("quantidade_quartos"));
    int quantidade_hospedes = Integer.parseInt(request.getParameter("quantidade_hospedes"));
    float preco = Float.parseFloat(request.getParameter("preco"));

    request.setAttribute("erroNome_hotel", service.validaNome(nome_hotel));
    request.setAttribute("erroData_entrada", service.validaEntrada(data_entrada));
    request.setAttribute("erroData_saida", service.validaSaida(data_saida));
    request.setAttribute("erroQuantidade_quartos", service.validaQuantidade_quartos(quantidade_quartos));
    request.setAttribute("erroQuantidade_hospedes", service.validaQuantidade_hospedes(quantidade_hospedes));
    request.setAttribute("erroPreco", service.validaPreco(preco));

    Hotel hotel = new Hotel(nome_hotel.trim(), data_entrada.trim(), data_saida.trim(),
            quantidade_quartos, quantidade_hospedes, preco, true);

    if (service.validaHotel(nome_hotel, quantidade_quartos, data_entrada, data_saida, quantidade_hospedes, preco)) {
        RequestDispatcher dispatcher = request.getRequestDispatcher("WEB-INF/jsp/CadastroHotel.jsp");
        dispatcher.forward(request, response);
    } else {
        try {

            dao.inserir(hotel);
            HttpSession sessao = request.getSession();
            int identificacaoF = (int) sessao.getAttribute("id_func");
            relatorio.setId_func(identificacaoF);
            relatorio.setMudanca("Cadastro de hotel efetuado!");
            relatorioDAO.inserir(relatorio);
            response.sendRedirect(request.getContextPath() + "/inicio");

        } catch (Exception ex) {

            Logger.getLogger(CadastroHotelServlet.class.getName()).log(Level.SEVERE, null, ex);

        }
    }
}
 
Example 8
Project: ipayquery   File: SessionUtil.java   View Source Code Vote up 5 votes
/**
 * 检测Session对象是否有效
 *
 * @param request
 * @return
 */
public static boolean sessionCheck(HttpSession session) {
    if (session.getAttribute(Const.SESSION_USER) == null) {
        return false;
    }
    return true;
}
 
Example 9
Project: unitimes   File: RoomListForm.java   View Source Code Vote up 5 votes
public void load(HttpSession session) {
      iMinRoomSize = (String)session.getAttribute("RoomList.MinRoomSize");
      iMaxRoomSize = (String)session.getAttribute("RoomList.MaxRoomSize");
      iFilter = (String)session.getAttribute("RoomList.Filter");
      iRoomTypes = (Long[]) session.getAttribute("RoomList.RoomTypes");
      iRoomGroups = (Long[]) session.getAttribute("RoomList.RoomGroups");
iRoomFeatures = (Long[]) session.getAttribute("RoomList.RoomFeatures");
  }
 
Example 10
Project: MMall_JAVA   File: CartController.java   View Source Code Vote up 5 votes
@RequestMapping("select_all.do")
public ServerResponse<CartVo> selectAll(HttpSession session) {
    User user = (User) session.getAttribute(Const.CURRENT_USER);
    if (user == null) {
        return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), ResponseCode.NEED_LOGIN.getDesc());
    }
    return iCartService.selectOrUnSelect(user.getId(), null, Const.Cart.CHECKED);
}
 
Example 11
Project: Equella   File: UserSessionServiceImpl.java   View Source Code Vote up 5 votes
private void setAttributeInternal(HttpSession session, String key, Object attribute)
{
	final String realKey = getKey(key);
	SerialisedValue<?> oldValue = (SerialisedValue<?>) session.getAttribute(realKey);
	SerialisedValue<?> newValue = new SerialisedValue<Object>(attribute);
	if( oldValue == null || !Arrays.equals(oldValue.getData(), newValue.getData()) )
	{
		session.setAttribute(realKey, newValue);
	}
}
 
Example 12
Project: full-javaee-app   File: CandidateAuthenticationFilter.java   View Source Code Vote up 5 votes
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
		throws IOException, ServletException {

	HttpSession session = ((HttpServletRequest) request).getSession();

	if (session.getAttribute("user") == null) {
		session.setAttribute("error",
				"You have been logged out due to inactivity or invalid authentication. Please login again.");
		((HttpServletResponse) response).sendRedirect("candidate-login.jsp");
	} else {
		chain.doFilter(request, response);
	}

}
 
Example 13
Project: lams   File: MonitoringAction.java   View Source Code Vote up 4 votes
private ActionForward summary(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

initializeScratchieService();
// initialize Session Map
SessionMap<String, Object> sessionMap = new SessionMap<String, Object>();
request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap);
request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());

Long contentId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID);
List<GroupSummary> summaryList = service.getMonitoringSummary(contentId, true);

Scratchie scratchie = service.getScratchieByContentId(contentId);
Set<ScratchieUser> learners = service.getAllLeaders(contentId);

//set SubmissionDeadline, if any
if (scratchie.getSubmissionDeadline() != null) {
    Date submissionDeadline = scratchie.getSubmissionDeadline();
    HttpSession ss = SessionManager.getSession();
    UserDTO teacher = (UserDTO) ss.getAttribute(AttributeNames.USER);
    TimeZone teacherTimeZone = teacher.getTimeZone();
    Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(teacherTimeZone, submissionDeadline);
    request.setAttribute(ScratchieConstants.ATTR_SUBMISSION_DEADLINE, tzSubmissionDeadline.getTime());
    request.setAttribute(ScratchieConstants.ATTR_SUBMISSION_DEADLINE_DATESTRING, DateUtil.convertToStringForJSON(submissionDeadline, request.getLocale()));
}

// cache into sessionMap
boolean isGroupedActivity = service.isGroupedActivity(contentId);
sessionMap.put(ScratchieConstants.ATTR_IS_GROUPED_ACTIVITY, isGroupedActivity);
sessionMap.put(ScratchieConstants.ATTR_SUMMARY_LIST, summaryList);
sessionMap.put(ScratchieConstants.ATTR_SCRATCHIE, scratchie);
sessionMap.put(ScratchieConstants.ATTR_LEARNERS, learners);
sessionMap.put(ScratchieConstants.ATTR_TOOL_CONTENT_ID, contentId);
sessionMap.put(AttributeNames.PARAM_CONTENT_FOLDER_ID,
	WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID));
sessionMap.put(ScratchieConstants.ATTR_REFLECTION_ON, scratchie.isReflectOnActivity());

// Create BurningQuestionsDtos if BurningQuestions is enabled.
if (scratchie.isBurningQuestionsEnabled()) {
    List<BurningQuestionItemDTO> burningQuestionItemDtos = service.getBurningQuestionDtos(scratchie, null, true);
    sessionMap.put(ScratchieConstants.ATTR_BURNING_QUESTION_ITEM_DTOS, burningQuestionItemDtos);
}

// Create reflectList if reflection is enabled.
if (scratchie.isReflectOnActivity()) {
    List<ReflectDTO> reflections = service.getReflectionList(contentId);
    sessionMap.put(ScratchieConstants.ATTR_REFLECTIONS, reflections);
}

return mapping.findForward(ScratchieConstants.SUCCESS);
   }
 
Example 14
Project: lams   File: WorkspaceAction.java   View Source Code Vote up 4 votes
private Integer getUserId() {
// return new Integer(WebUtil.readIntParam(request,AttributeNames.PARAM_USER_ID));
HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
return user != null ? user.getUserID() : null;
   }
 
Example 15
Project: otter-G   File: CanalList.java   View Source Code Vote up 4 votes
public void execute(HttpSession session, @Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, Context context)
                                                                                                     throws Exception {
	@SuppressWarnings("unchecked")
    Map<String, Object> condition = new HashMap<String, Object>();
    if ("请输入关键字(目前支持Node的ID、名字搜索)".equals(searchKey)) {
        searchKey = "";
    }
    condition.put("searchKey", searchKey);
    
    //System.out.println("cannal列表:"+pageIndex+","+);
	User userInfo = (User) session.getAttribute(WebConstant.USER_SESSION_KEY);
    if(userInfo != null && userInfo.getAuthorizeType().isAdmin())//确定是否进行过滤
    	condition.put("userId", userInfo.getId());

    int count = canalService.getCount(condition);
    Paginator paginator = new Paginator();
    paginator.setItems(count);
    paginator.setPage(pageIndex);

    condition.put("offset", paginator.getOffset());
    condition.put("length", paginator.getLength());

    List<Canal> canals = canalService.listByCondition(condition);

    List<SeniorCanal> seniorCanals = new ArrayList<SeniorCanal>();

    for (Canal canal : canals) {
    	SeniorCanal seniorCanal = new SeniorCanal();
        seniorCanal.setId(canal.getId());
        seniorCanal.setName(canal.getName());
        seniorCanal.setStatus(canal.getStatus());
        seniorCanal.setDesc(canal.getDesc());
        seniorCanal.setCanalParameter(canal.getCanalParameter());
        seniorCanal.setGmtCreate(canal.getGmtCreate());
        seniorCanal.setGmtModified(canal.getGmtModified());

        List<Pipeline> pipelines = pipelineService.listByDestinationWithoutOther(canal.getName());
        seniorCanal.setPipelines(pipelines);
        seniorCanal.setUsed(!pipelines.isEmpty());
        seniorCanals.add(seniorCanal);
    }
    context.put("seniorCanals", seniorCanals);
    context.put("paginator", paginator);
    context.put("searchKey", searchKey);
}
 
Example 16
Project: lazycat   File: RestCsrfPreventionFilter.java   View Source Code Vote up 4 votes
protected String extractNonceFromSession(HttpSession session, String key) {
	return session == null ? null : (String) session.getAttribute(key);
}
 
Example 17
Project: full-javaee-app   File: CandidateAccountServlet.java   View Source Code Vote up 4 votes
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String email = request.getParameter("email").toLowerCase().trim(), password = request.getParameter("password"),
            authorized = request.getParameter("authorized");

    HttpSession session = request.getSession();

    if (email.isEmpty() || password.isEmpty()) {
        session.setAttribute("error", "Please enter a valid e-mail and password.");
        response.sendRedirect("candidate-account.jsp");
        return;
    } else if (password.length() < 4) {
        session.setAttribute("error", "Password must be greater than 3 characters/");
        response.sendRedirect("candidate-account.jsp");
        return;
    }

    if (session.getAttribute("user") != null) {
        Candidates candidate = (Candidates) session.getAttribute("user");

        try {
            int candidateID = candidate.getCandidateID();
            candidate = CandidatePersistence.getCandidateByID(candidateID);
            CustomUtilities custom = new CustomUtilities();
            String[] passwordArray = custom.hashPassword(password, null);
            candidate.setPassword(passwordArray[0]);
            candidate.setSalt(passwordArray[1]);
            candidate.setEmail(email);
            candidate.setAuthorized(authorized);
            CandidatePersistence.merge(candidate);
            session.setAttribute("user", candidate);
            session.setAttribute("error", "Details updated");
            response.sendRedirect("candidate-account.jsp");
        } catch (Exception e) {
            e.printStackTrace();
            session.setAttribute("error", "Your account is currently experiencing technical difficulties, please try again soon.");
            response.sendRedirect("candidate-account.jsp");
            return;
        }
    } else {
        session.setAttribute("error", "Your account is currently experiencing technical difficulties, please try again soon.");
        response.sendRedirect("candidate-account.jsp");
    }
}
 
Example 18
Project: lams   File: MonitoringAction.java   View Source Code Vote up 4 votes
private ActionForward summary(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {
initAssessmentService();

// initialize Session Map
SessionMap<String, Object> sessionMap = new SessionMap<String, Object>();
request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap);
request.setAttribute(AssessmentConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());

Long contentId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID);
List<SessionDTO> sessionDtos = service.getSessionDtos(contentId, false);

Assessment assessment = service.getAssessmentByContentId(contentId);

//set SubmissionDeadline, if any
if (assessment.getSubmissionDeadline() != null) {
    Date submissionDeadline = assessment.getSubmissionDeadline();
    HttpSession ss = SessionManager.getSession();
    UserDTO teacher = (UserDTO) ss.getAttribute(AttributeNames.USER);
    TimeZone teacherTimeZone = teacher.getTimeZone();
    Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(teacherTimeZone, submissionDeadline);
    request.setAttribute(AssessmentConstants.ATTR_SUBMISSION_DEADLINE, tzSubmissionDeadline.getTime());
    // use the unconverted time, as convertToStringForJSON() does the timezone conversion if needed
    request.setAttribute(AssessmentConstants.ATTR_SUBMISSION_DEADLINE_DATESTRING, DateUtil.convertToStringForJSON(submissionDeadline, request.getLocale()));

}

// Create reflectList if reflection is enabled.
if (assessment.isReflectOnActivity()) {
    List<ReflectDTO> reflectList = service.getReflectList(assessment.getContentId());
    // Add reflectList to sessionMap
    sessionMap.put(AssessmentConstants.ATTR_REFLECT_LIST, reflectList);
}

//prepare list of the questions to display in question drop down menu, filtering out questions that aren't supposed to be answered
Set<AssessmentQuestion> questionList = new TreeSet<AssessmentQuestion>();
//in case there is at least one random question - we need to show all questions in a drop down select
if (assessment.hasRandomQuestion()) {
    questionList.addAll(assessment.getQuestions());

    //show only questions from question list otherwise
} else {
    for (QuestionReference reference : (Set<QuestionReference>) assessment.getQuestionReferences()) {
	questionList.add(reference.getQuestion());
    }
}

//prepare toolOutputDefinitions and activityEvaluation
List<String> toolOutputDefinitions = new ArrayList<String>();
toolOutputDefinitions.add(AssessmentConstants.OUTPUT_NAME_LEARNER_TOTAL_SCORE);
toolOutputDefinitions.add(AssessmentConstants.OUTPUT_NAME_BEST_SCORE);
toolOutputDefinitions.add(AssessmentConstants.OUTPUT_NAME_FIRST_SCORE);
toolOutputDefinitions.add(AssessmentConstants.OUTPUT_NAME_AVERAGE_SCORE);
String activityEvaluation = service.getActivityEvaluation(contentId);
sessionMap.put(AssessmentConstants.ATTR_TOOL_OUTPUT_DEFINITIONS, toolOutputDefinitions);
sessionMap.put(AssessmentConstants.ATTR_ACTIVITY_EVALUATION, activityEvaluation);

// cache into sessionMap
boolean isGroupedActivity = service.isGroupedActivity(contentId);
sessionMap.put(AssessmentConstants.ATTR_IS_GROUPED_ACTIVITY, isGroupedActivity);
sessionMap.put("sessionDtos", sessionDtos);
sessionMap.put(AssessmentConstants.ATTR_ASSESSMENT, assessment);
sessionMap.put(AssessmentConstants.ATTR_QUESTION_LIST, questionList);
sessionMap.put(AssessmentConstants.ATTR_TOOL_CONTENT_ID, contentId);
sessionMap.put(AttributeNames.PARAM_CONTENT_FOLDER_ID,
	WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID));
return mapping.findForward(AssessmentConstants.SUCCESS);
   }
 
Example 19
Project: CMSdemo   File: ExcelController.java   View Source Code Vote up 4 votes
@PostMapping("/taskExcel")
public void taskExcel(HttpSession session, HttpServletResponse response,String userId,String startDate,String endDate){
    //获取list
    Map<String,Object> map=new HashMap<>();
    if(userId!=null&&userId.length()>0){
        map.put("userId",userId);
    }
    if(startDate!=null&&endDate!=null){
        map.put("startDate", StringUtils.trimAllWhitespace(startDate));
        map.put("endDate",StringUtils.trimAllWhitespace(endDate));
    }
    String userSessionId= (String) session.getAttribute("userSessionId");
    List<Advertise> advertises=advertiseService.findConditions(map,userSessionId);
    //excel
    HSSFWorkbook workbook=new HSSFWorkbook();
    HSSFSheet sheet=workbook.createSheet();
    //header
    String[] headers={"UserID","URL"};
    HSSFRow row=sheet.createRow(0);
    for(int i=0;i<headers.length;i++){
        HSSFCell cell=row.createCell(i);
        cell.setCellValue(headers[i]);
    }

    int rows=1;
    for(Advertise advertise:advertises){
        HSSFRow dataRow=sheet.createRow(rows++);

        newCell(0,dataRow).setCellValue(objectToString(advertise.getUserId()));

        newCell(1,dataRow).setCellValue(objectToString(advertise.getUrl()));
    }

    String filename=startDate==null||endDate==null?userSessionId:userSessionId+"("+startDate+"to"+endDate+")";
    response.setContentType("application/octet-stream");
    response.setHeader("Content-disposition","attachment;filename="+filename+"-taskExcel.xls");
    try {
        response.flushBuffer();
        workbook.write(response.getOutputStream());
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 20
Project: cas4.0.x-server-wechat   File: ClientAction.java   View Source Code Vote up 2 votes
/**
 * Restore an attribute in web session as an attribute in request.
 *
 * @param request The HTTP request
 * @param session The HTTP session
 * @param name The name of the parameter
 */
private void restoreRequestAttribute(final HttpServletRequest request, final HttpSession session,
        final String name) {
    final String value = (String) session.getAttribute(name);
    request.setAttribute(name, value);
}