Java Code Examples for javax.servlet.http.HttpServletRequest#getParameter()
The following examples show how to use
javax.servlet.http.HttpServletRequest#getParameter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AllRequestsServlet.java From stepic_java_webserver with MIT License | 6 votes |
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Map<String, Object> pageVariables = createPageVariablesMap(request); String message = request.getParameter("message"); response.setContentType("text/html;charset=utf-8"); if (message == null || message.isEmpty()) { response.setStatus(HttpServletResponse.SC_FORBIDDEN); } else { response.setStatus(HttpServletResponse.SC_OK); } pageVariables.put("message", message == null ? "" : message); response.getWriter().println(PageGenerator.instance().getPage("page.html", pageVariables)); }
Example 2
Source File: AdminDao.java From StudentManagement with MIT License | 6 votes |
protected void alter_sc(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=utf-8"); String sno = request.getParameter("sno"); String cno = request.getParameter("cno"); double after_grade = Double.parseDouble(request.getParameter("after_grade")); int flag = new SCDao().alter_sc(sno, cno, after_grade); String info = null; PrintWriter out = response.getWriter(); if (flag == 1) { info = sno + "号学生" + cno + "号课程成绩修改成功!"; } else { info = "错误:修改学生成绩失败!"; } out.write("<div class='error'>"); out.write("<div>" + info + "</div>"); out.write("</div>"); out.flush(); out.close(); }
Example 3
Source File: ShoppingCarManagerServlet.java From TourismWebsite with MIT License | 6 votes |
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String flag=request.getParameter("flag"); System.out.println(flag); if("_seeCar".equals(flag)){ this.seeShoppingCar(request, response); }else if("_addCar".equals(flag)){ this.AddtoShoppingCar(request, response); }else if("_remove".equals(flag)){ this.removeLineFromCart(request, response); } }
Example 4
Source File: ZkMediaSourceController.java From DataLink with Apache License 2.0 | 6 votes |
@ResponseBody @RequestMapping(value = "/checkZk") public String checkZk(HttpServletRequest request) { String id = request.getParameter("id"); try { MediaSourceInfo mediaSourceInfo = new MediaSourceInfo(); if (StringUtils.isNotBlank(id)) { mediaSourceInfo = mediaSourceService.getById(Long.valueOf(id)); } JSONObject jsonObject = JSON.parseObject(mediaSourceInfo.getParameter()); jsonObject.remove("@type"); ZkMediaSrcParameter zkMediaSrcParameter = JSON.parseObject(jsonObject.toString(), ZkMediaSrcParameter.class); ZkMediaSourceView zkMediaSourceView = new ZkMediaSourceView(); zkMediaSourceView.setZkMediaSrcParameter(zkMediaSrcParameter); checkZkServers(zkMediaSourceView); return "success"; } catch (Exception e) { return e.getMessage(); } }
Example 5
Source File: AcademicServiceRequestsManagementDispatchAction.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 6 votes |
public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { final AcademicServiceRequestBean bean = getOrCreateAcademicServiceRequestBean(request); request.setAttribute("bean", bean); final Collection<AcademicServiceRequest> remainingRequests = bean.searchAcademicServiceRequests(); final Collection<AcademicServiceRequest> specificRequests = getAndRemoveSpecificRequests(bean, remainingRequests); final SortedSet<AcademicServiceRequest> sorted = new TreeSet<AcademicServiceRequest>(getComparator(request)); sorted.addAll(remainingRequests); request.setAttribute("remainingRequests", remainingRequests); request.setAttribute("specificRequests", specificRequests); final CollectionPager<AcademicServiceRequest> pager = new CollectionPager<AcademicServiceRequest>(sorted, REQUESTS_PER_PAGE); request.setAttribute("collectionPager", pager); request.setAttribute("numberOfPages", Integer.valueOf(pager.getNumberOfPages())); final String pageParameter = request.getParameter("pageNumber"); final Integer page = StringUtils.isEmpty(pageParameter) ? Integer.valueOf(1) : Integer.valueOf(pageParameter); request.setAttribute("pageNumber", page); request.setAttribute("resultPage", pager.getPage(page)); return mapping.findForward("searchResults"); }
Example 6
Source File: JWTTokenAsUserUniqueIdentifierSsoService.java From Knowage-Server with GNU Affero General Public License v3.0 | 6 votes |
public String readUserIdentifier(HttpServletRequest request) { try { String jwtToken = request.getParameter(SsoServiceInterface.USER_ID); if (jwtToken == null) { logger.debug("JWT token not found in request"); return null; } logger.debug("JWT token retrieved : [" + jwtToken + "]"); JWTVerifier verifier = JWT.require(algorithm).build(); verifier.verify(jwtToken); logger.debug("JWT token verified properly"); return jwtToken; // we consider the JWT token as user unique identifier } catch (JWTVerificationException e) { throw new SpagoBIRuntimeException("Invalid JWT token!", e); } }
Example 7
Source File: BruteForceServlet.java From easybuggy with Apache License 2.0 | 6 votes |
@Override public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { Locale locale = req.getLocale(); String userid = req.getParameter("userid"); String password = req.getParameter("password"); HttpSession session = req.getSession(true); if (authUser(userid, password)) { session.setAttribute("authNMsg", "authenticated"); session.setAttribute("userid", userid); String target = (String) session.getAttribute("target"); if (target == null) { res.sendRedirect("/admins/main"); } else { session.removeAttribute("target"); res.sendRedirect(target); } } else { session.setAttribute("authNMsg", getErrMsg("msg.authentication.fail", locale)); doGet(req, res); } }
Example 8
Source File: LoginController.java From mcg-helper with Apache License 2.0 | 5 votes |
@RequestMapping(value = "/login", method = RequestMethod.POST) public ModelAndView index(HttpServletRequest reuqest, HttpServletResponse response) { ModelAndView mv = this.getModelAndView(); if(reuqest.getHeader("x-requested-with")!=null && reuqest.getHeader("x-requested-with").equalsIgnoreCase("XMLHttpRequest")){ //不记录上次登录的url mv.setViewName("timeout"); } else { UserCacheBean ucb = PermissionCollection.getInstance().getUserCache(reuqest.getSession().getId()); if(ucb == null ) { if(reuqest.getParameter("userKey") != null && !"".equals(reuqest.getParameter("userKey"))) { ucb = new UserCacheBean(); ucb.setSessionID(reuqest.getSession().getId()); McgUser mu = new McgUser(); mu.setUserKey(reuqest.getParameter("userKey")); ucb.setUser(mu); PermissionCollection.getInstance().addSessionUserCache(reuqest.getSession().getId(), ucb); mv.setViewName("redirect:/index"); } else { mv.setViewName("redirect:/login.jsp"); } } else { mv.setViewName("redirect:/index"); } } return mv; }
Example 9
Source File: CloneLessonsController.java From lams with GNU General Public License v2.0 | 5 votes |
@RequestMapping(path = "/clone", method = RequestMethod.POST) public String clone(HttpServletRequest request) throws Exception { Integer groupId = WebUtil.readIntParam(request, "groupId", false); String lessons = request.getParameter("lessons"); String staff = request.getParameter("staff"); String learners = request.getParameter("learners"); Boolean addAllStaff = WebUtil.readBooleanParam(request, "addAllStaff", false); Boolean addAllLearners = WebUtil.readBooleanParam(request, "addAllLearners", false); String[] lessonIds = new String[0], staffIds = new String[0], learnerIds = new String[0]; if (StringUtils.isNotEmpty(lessons)) { lessonIds = lessons.split(","); } if (StringUtils.isNotEmpty(staff)) { staffIds = staff.split(","); } if (StringUtils.isNotEmpty(learners)) { learnerIds = learners.split(","); } int result = 0; Organisation group = (Organisation) userManagementService.findById(Organisation.class, groupId); if (group != null) { result = monitoringService.cloneLessons(lessonIds, addAllStaff, addAllLearners, staffIds, learnerIds, group); } else { throw new UserException("Couldn't find Organisation based on id=" + groupId); } request.setAttribute("org", group); request.setAttribute("result", result); return "organisation/cloneResult"; }
Example 10
Source File: ThirdPartyLoginController.java From mumu with Apache License 2.0 | 5 votes |
@RequestMapping("callback/sina") public String sinaCallback(HttpServletRequest request, ModelMap modelMap) { String host = request.getHeader("host"); try { String code = request.getParameter("code"); if (StringUtils.isNotBlank(code)) {// 如果不为空 // 获取token和uid JSONObject json = ThirdPartyLoginHelper.getSinaTokenAndUid(code, host); String uid = json.getString("uid"); if (StringUtils.isNotBlank(uid)) {// 如果uid存在 // 获取第三方用户信息存放到session中 ThirdPartyUser thirdUser = ThirdPartyLoginHelper.getSinaUserinfo(json.getString("access_token"), uid); thirdUser.setProvider("SINA"); thirdPartyLogin(request, thirdUser); // 跳转到登录成功界面 modelMap.put("retUrl", Resources.THIRDPARTY.getString("third_login_success")); } else {// 如果未获取到OpenID // 跳转到登录成功界面 modelMap.put("retUrl", "-1"); } } else {// 如果没有返回令牌,则直接返回到登录页面 // 跳转到登录成功界面 modelMap.put("retUrl", "-1"); } } catch (Exception e) { // 跳转到登录失败界面 modelMap.put("retUrl", "-1"); e.printStackTrace(); } return "/sns/redirect"; }
Example 11
Source File: CgAutoListController.java From jeewx with Apache License 2.0 | 5 votes |
/** * 加载URL中的过滤参数[在未配置查询字段的情况下,作为hidden控件使用] * @param queryList * @param bean * @param request */ @SuppressWarnings("unchecked") private void loadUrlDataFilter(List<Map> queryList, CgFormFieldEntity bean, HttpServletRequest request) { String paramV = request.getParameter(bean.getFieldName()); String paramVbegin = request.getParameter(bean.getFieldName()+"_begin"); String paramVend = request.getParameter(bean.getFieldName()+"_end"); if(bean.getFieldName().equalsIgnoreCase("id")){ return; } for(Map mq:queryList){ if(mq.containsValue(bean.getFieldName())){ return; } } if(!StringUtil.isEmpty(paramV) || !StringUtil.isEmpty(paramVbegin) ||!StringUtil.isEmpty(paramVend)){ Map fmq = new HashMap<String, Object>(); fmq.put(CgAutoListConstant.FILED_ID, bean.getFieldName()); fmq.put(CgAutoListConstant.FIELD_TITLE, bean.getContent()); fmq.put(CgAutoListConstant.FIELD_QUERYMODE, bean.getQueryMode()); fmq.put(CgAutoListConstant.FIELD_TYPE, bean.getType()); fmq.put(CgAutoListConstant.FIELD_ISQUERY,"N"); paramV = SysVar.getSysVar(paramV); fmq.put(CgAutoListConstant.FIELD_VALUE, paramV); paramVbegin = SysVar.getSysVar(paramVbegin); paramVend = SysVar.getSysVar(paramVend); fmq.put(CgAutoListConstant.FIELD_VALUE_BEGIN, StringUtil.isEmpty(paramVbegin)?"":paramVbegin); fmq.put(CgAutoListConstant.FIELD_VALUE_END, StringUtil.isEmpty(paramVend)?"":paramVend); queryList.add(fmq); } }
Example 12
Source File: TaggedThreadListAction.java From jivejdon with Apache License 2.0 | 5 votes |
public PageIterator getPageIterator(HttpServletRequest request, int start, int count) { TagService othersService = (TagService) WebAppUtil.getService("othersService", this.servlet.getServletContext()); String tagID = request.getParameter("tagID"); if (tagID == null || !UtilValidate.isInteger(tagID) || tagID.length()>10) { return new PageIterator(); } ThreadTag tag = othersService.getThreadTag(new Long(tagID)); if (tag == null) return new PageIterator(); request.setAttribute("TITLE", tag.getTitle()); request.setAttribute("threadTag", tag); TaggedThreadListSpec taggedThreadListSpec = new TaggedThreadListSpec(); taggedThreadListSpec.setTagID(new Long(tagID)); return othersService.getTaggedThread(taggedThreadListSpec, start, count); }
Example 13
Source File: IvmContextServlet.java From tomee with Apache License 2.0 | 5 votes |
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { final PrintWriter writer = resp.getWriter(); final String testToExecute = req.getParameter("test"); try { final Method method = this.getClass().getDeclaredMethod(testToExecute, PrintWriter.class); method.invoke(this, writer); writer.println(testToExecute + "=true"); } catch (Exception ex) { final Throwable rootCause = ex instanceof InvocationTargetException ? ex.getCause() : ex; writer.println(testToExecute + "=false"); rootCause.printStackTrace(writer); } }
Example 14
Source File: Register.java From Spring5Tutorial with GNU Lesser General Public License v3.0 | 5 votes |
protected void doPost( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String email = request.getParameter("email"); String username = request.getParameter("username"); String password = request.getParameter("password"); String password2 = request.getParameter("password2"); List<String> errors = new ArrayList<>(); if (!validateEmail(email)) { errors.add("未填寫郵件或格式不正確"); } if(!validateUsername(username)) { errors.add("未填寫使用者名稱或格式不正確"); } if (!validatePassword(password, password2)) { errors.add("請確認密碼符合格式並再度確認密碼"); } String path; if(errors.isEmpty()) { path = getInitParameter("SUCCESS_PATH"); UserService userService = (UserService) getServletContext().getAttribute("userService"); EmailService emailService = (EmailService) getServletContext().getAttribute("emailService"); Optional<Account> optionalAcct = userService.tryCreateUser(email, username, password); if(optionalAcct.isPresent()) { emailService.validationLink(optionalAcct.get()); } else { emailService.failedRegistration(username, email); } } else { path = getInitParameter("FORM_PATH"); request.setAttribute("errors", errors); } request.getRequestDispatcher(path).forward(request, response); }
Example 15
Source File: StyleSheetJspBean.java From lutece-core with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Displays the stylesheets list * * @return the html code for displaying the stylesheets list * @param request * The request */ public String getManageStyleSheet( HttpServletRequest request ) { // Parameters processing String strModeId = request.getParameter( Parameters.MODE_ID ); strModeId = ( strModeId != null ) ? strModeId : "-1"; int nModeId = Integer.parseInt( strModeId ); ReferenceList listModes = ModeHome.getModes( ); String strComboItem = I18nService.getLocalizedString( LABEL_ALL, getLocale( ) ); listModes.addItem( -1, strComboItem ); List<StyleSheet> listStyleSheets = (List<StyleSheet>) StyleSheetHome.getStyleSheetList( nModeId ); String strSortedAttributeName = request.getParameter( Parameters.SORTED_ATTRIBUTE_NAME ); String strAscSort = null; if ( strSortedAttributeName != null ) { strAscSort = request.getParameter( Parameters.SORTED_ASC ); boolean bIsAscSort = Boolean.parseBoolean( strAscSort ); Collections.sort( listStyleSheets, new AttributeComparator( strSortedAttributeName, bIsAscSort ) ); } int defaultItemsPerPage = AppPropertiesService.getPropertyInt( PROPERTY_STYLESHEETS_PER_PAGE, 50 ); _strCurrentPageIndex = AbstractPaginator.getPageIndex( request, AbstractPaginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex ); _nItemsPerPage = AbstractPaginator.getItemsPerPage( request, AbstractPaginator.PARAMETER_ITEMS_PER_PAGE, _nItemsPerPage, defaultItemsPerPage ); String strURL = getHomeUrl( request ); if ( strSortedAttributeName != null ) { strURL += ( "?" + Parameters.SORTED_ATTRIBUTE_NAME + "=" + strSortedAttributeName ); } if ( strAscSort != null ) { strURL += ( "&" + Parameters.SORTED_ASC + "=" + strAscSort ); } LocalizedPaginator<StyleSheet> paginator = new LocalizedPaginator<>( listStyleSheets, _nItemsPerPage, strURL, AbstractPaginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex, getLocale( ) ); Map<String, Object> model = new HashMap<>( ); model.put( MARK_MODE_ID, strModeId ); model.put( MARK_NB_ITEMS_PER_PAGE, "" + _nItemsPerPage ); model.put( MARK_PAGINATOR, paginator ); model.put( MARK_STYLESHEET_LIST, paginator.getPageItems( ) ); model.put( MARK_MODE_LIST, listModes ); HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MANAGE_STYLESHEETS, getLocale( ), model ); return getAdminPage( template.getHtml( ) ); }
Example 16
Source File: ValueExtractors.java From proctor with Apache License 2.0 | 4 votes |
public String extract(final HttpServletRequest request) { return request.getParameter(sourceKey); }
Example 17
Source File: FunctionController.java From jeewx with Apache License 2.0 | 4 votes |
/** * 菜单模糊检索功能 * * @return */ @RequestMapping(params = "searchApp") public ModelAndView searchApp(TSFunction function, HttpServletRequest req) { String name = req.getParameter("name"); String menuListMap = ""; // String menuListMap = "<div class='appListContainer ui-sortable' customacceptdrop='0' index='0' _olddisplay='block' style='width: auto; height: auto; margin-left: 10px; margin-top: 10px; display: block;'>"; CriteriaQuery cq = new CriteriaQuery(TSFunction.class); cq.notEq("functionLevel", Short.valueOf("0")); if (name == null || "".equals(name)) { cq.isNull("TSFunction"); }else{ String name1 = "%"+name+"%"; cq.like("functionName", name1); } cq.add(); List<TSFunction> functionList = systemService.getListByCriteriaQuery(cq, false); if(functionList.size() > 0 && functionList != null){ for(int i = 0; i < functionList.size(); i++){ // menuListMap = menuListMap + "<div id='menuList_area' class='menuList_area'>"; String icon = ""; if(!"".equals(functionList.get(i).getTSIconDesk()) && functionList.get(i).getTSIconDesk() != null){ icon = functionList.get(i).getTSIconDesk().getIconPath(); }else{ icon = "plug-in/sliding/icon/default.png"; } menuListMap = menuListMap + "<div type='"+i+1+"' class='menuSearch_Info' id='"+functionList.get(i).getId()+"' title='"+functionList.get(i).getFunctionName()+"' url='"+functionList.get(i).getFunctionUrl()+"' icon='"+icon+"' style='float:left;left: 0px; top: 0px;margin-left: 30px;margin-top: 20px;'>" + "<div ><img alt='"+functionList.get(i).getFunctionName()+"' src='"+icon+"'></div>" + "<div class='appButton_appName_inner1' style='color:#333333;'>"+functionList.get(i).getFunctionName()+"</div>" + "<div class='appButton_appName_inner_right1'></div>" + // "</div>" + "</div>"; } }else{ menuListMap = menuListMap + "很遗憾,在系统中没有检索到与“"+name+"”相关的信息!"; } // menuListMap = menuListMap + "</div>"; org.jeecgframework.core.util.LogUtil.info("-------------------------------"+menuListMap); req.setAttribute("menuListMap", menuListMap); return new ModelAndView("system/function/menuAppList"); }
Example 18
Source File: DefectController.java From seppb with MIT License | 4 votes |
@PostMapping(value = "/defect/query") public PageInfo<Defect> defectQuery(HttpServletRequest request) { Map<String, Object> dataMap = new HashMap<>(); Map<String, Object> userMap = new HashMap<>(); userMap.put(PRODUCT_ID, ParameterThreadLocal.getProductId()); List<User> users = userService.userQuery(userMap); String status = request.getParameter(CommonParameter.STATUS); if (!StringUtils.isEmpty(status)) { dataMap.put("sts", Arrays.asList(status.split(","))); } dataMap.put(REQ_ID, request.getParameter(REQ_ID)); dataMap.put(PRODUCT_ID, ParameterThreadLocal.getProductId()); dataMap.put(REL_ID, request.getParameter(REL_ID)); dataMap.put(ID, request.getParameter(ID)); dataMap.put(SUBMITTER, request.getParameter(SUBMITTER)); dataMap.put(RESPONSER, request.getParameter(RESPONSER)); dataMap.put("priority", request.getParameter("priority")); dataMap.put("influence", request.getParameter("influence")); dataMap.put("conciliator", request.getParameter("conciliator")); dataMap.put("prodModule", request.getParameter("prodModule")); dataMap.put("foundPeriod", request.getParameter("foundPeriod")); dataMap.put("defectPeriod", request.getParameter("defectPeriod")); dataMap.put("defectType", request.getParameter("defectType")); if (!StringUtils.isEmpty(request.getParameter("foundTimeBegin"))) { dataMap.put("foundTimeBegin", request.getParameter("foundTimeBegin") + " 00:00:00"); } if (!StringUtils.isEmpty(request.getParameter("foundTimeEnd"))) { dataMap.put("foundTimeEnd", request.getParameter("foundTimeEnd") + " 23:59:59"); } PageHelper.startPage(ParameterThreadLocal.getPageNum(), ParameterThreadLocal.getPageSize()); List<Defect> defects = defectService.defectQuery(dataMap); defects.forEach(item -> { String subName = users.stream().filter(u -> Objects.equals(u.getUserId(), item.getSubmitter())).findFirst().orElse(new User()).getUserName(); String conName = users.stream().filter(u -> Objects.equals(u.getUserId(), item.getConciliator())).findFirst().orElse(new User()).getUserName(); String resName = users.stream().filter(u -> Objects.equals(u.getUserId(), item.getResponser())).findFirst().orElse(new User()).getUserName(); // 缺陷对应产品经理在无归属需求时清空 String proName = item.getReqId() - 0 == 0 ? "/" : users.stream().filter(u -> Objects.equals(u.getUserId(), item.getProductor())).findFirst().orElse(new User()).getUserName(); item.setSubmitterName(subName); item.setConciliatorName(conName); item.setResponserName(resName); item.setProductorName(proName); }); PageInfo<Defect> pageInfo = new PageInfo<>(defects); return pageInfo; }
Example 19
Source File: ExampleThree.java From tutorials with MIT License | 4 votes |
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String message = request.getParameter("message"); request.setAttribute("text", message); request.getRequestDispatcher("/jsp/ExampleThree.jsp").forward(request, response); }
Example 20
Source File: ExecutionYearViewDA.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 4 votes |
public ActionForward showHome(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { User userView = Authenticate.getUser(); String degreeCurricularPlanID = request.getParameter("degreeCurricularPlanID"); DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanID); JsonArray executionYears = computeExecutionYearsForDegreeCurricularPlan(degreeCurricularPlan); request.setAttribute("executionYears", executionYears); String executionYearId = request.getParameter("executionYear"); ExecutionYear currentExecutionYear = ExecutionYear.readCurrentExecutionYear(); if (executionYearId != null) { currentExecutionYear = FenixFramework.getDomainObject(executionYearId); } request.setAttribute("degreeCurricularPlanID", degreeCurricularPlanID); request.setAttribute("currentExecutionYear", computeExecutionYearStatistics(degreeCurricularPlan, currentExecutionYear)); return mapping.findForward("showHome"); }