protected void sendRedirect(HttpServletRequest request, HttpServletResponse response, String targetUrl, boolean http10Compatible,boolean isforward,boolean isinclude) throws IOException { if(isloopredirect(request, targetUrl)) { response.sendError(HttpServletResponse.SC_FORBIDDEN); return; } if(!isforward) { targetUrl = appendDTokenToTargetURL(request, targetUrl); if(!isinclude) { if (http10Compatible) { // Always send status code 302. response.sendRedirect(response.encodeRedirectURL(targetUrl)); } else { // Correct HTTP status code is 303, in particular for POST requests. response.setStatus(303); response.setHeader("Location", response .encodeRedirectURL(targetUrl)); } } else { try { request.getRequestDispatcher(targetUrl).include(request, response); } catch (ServletException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } else { try { request.getRequestDispatcher(targetUrl).forward(request, response); } catch (ServletException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse rpo = (HttpServletResponse) response; javax.servlet.http.HttpSession session = req.getSession(); try { req.setCharacterEncoding("utf-8"); } catch (Exception e1) { e1.printStackTrace(); } String userId = (String) session.getAttribute("username"); if (userId != null) { try { chain.doFilter(request, response); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ServletException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { try { response.setCharacterEncoding("utf-8"); PrintWriter out = response.getWriter(); out.print("{'success':false,'msg':'未登录或登录失效'}"); out.flush(); out.close(); // rpo.sendRedirect("/login.jsp"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
public void handleParseStart(ParseContext pContext) throws IOException { ReplayParseContext context = (ReplayParseContext) pContext; String policy = context.getJspExec().getUiResults().getResult().getOraclePolicy(); if (policy != null) { context.setOraclePolicy(policy); } if (startJsp != null) { OutputStream out = context.getOutputStream(); String tmp = null; try { tmp = context.getJspExec().jspToString(startJsp); } catch (ServletException e) { e.printStackTrace(); } if (tmp != null) { // Charset charset = Charset.forName(context.getOutputCharset()); String charset = context.getOutputCharset(); out.write(tmp.getBytes(charset)); } } }
/** Retrieve {@link com.opensymphony.module.sitemesh.Decorator} based on 'pattern' tag. */ public Decorator getDecorator(HttpServletRequest request, Page page) { String thisPath = request.getServletPath(); // getServletPath() returns null unless the mapping corresponds to a servlet if (thisPath == null) { String requestURI = request.getRequestURI(); if (request.getPathInfo() != null) { // strip the pathInfo from the requestURI thisPath = requestURI.substring(0, requestURI.indexOf(request.getPathInfo())); } else { thisPath = requestURI; } } else if ("".equals(thisPath)) { // in servlet 2.4, if a request is mapped to '/*', getServletPath returns null (SIM-130) thisPath = request.getPathInfo(); } String name = null; try { name = configLoader.getMappedName(thisPath); } catch (ServletException e) { e.printStackTrace(); } Decorator result = getNamedDecorator(request, name); return result == null ? super.getDecorator(request, page) : result; }
@RequestMapping(value = "/autologin/user", method = RequestMethod.GET) public @ResponseBody ResponseEntity<Map<String, Object>> autologin1(HttpServletRequest request) { Map<String, Object> map = new HashMap<String, Object>(); HttpStatus status = null; try { request.login("author", "1"); map.put("MESSAGE", "AUTO LOG IN SUCCESS WITH DEFAULT AUTHOR ACCOUNT 'author'"); map.put("STATUS", "200"); map.put("IS_LOGIN", isAuthenticated()); map.put("ROLE", getRole()); map.put("USERNAME", getUsername()); status = HttpStatus.OK; } catch (ServletException e) { // TODO Auto-generated catch block map.put("MESSAGE", e.getMessage()); map.put("IS_LOGIN", isAuthenticated()); map.put("ROLE", getRole()); map.put("USERNAME", getUsername()); status = HttpStatus.BAD_REQUEST; e.printStackTrace(); return new ResponseEntity<Map<String, Object>>(map, status); } System.out.println(isAuthenticated()); System.out.println(getRole()); System.out.println(getUsername()); return new ResponseEntity<Map<String, Object>>(map, status); }
/** * Redirect the request to another page if the user is a Monitor type and the discrepancy note is * a type other than item data or event crf. * * @param module A String like "managestudy" or "admin" * @param discrepancyNoteBean */ private void redirectMonitor(String module, DiscrepancyNoteBean discrepancyNoteBean) { if (discrepancyNoteBean != null) { String createNoteURL = ""; // This String will determine whether the type is other than // itemdata. String entityType = discrepancyNoteBean.getEntityType().toLowerCase(); // The id of the subject, study subject, or study event int entityId = discrepancyNoteBean.getEntityId(); RequestDispatcher dispatcher = null; DiscrepancyNoteUtil discNoteUtil = new DiscrepancyNoteUtil(); if (entityType != null && !"".equalsIgnoreCase(entityType) && !"itemdata".equalsIgnoreCase(entityType) && !"eventcrf".equalsIgnoreCase(entityType)) { // redirect to View Study Subject // addPageMessage(resword.getString("monitors_do_not_have_permission_to_resolve_discrepancy_notes")); if ("studySub".equalsIgnoreCase(entityType)) { dispatcher = request.getRequestDispatcher( "/ViewStudySubject?id=" + entityId + "&module=" + module); discrepancyNoteBean.setSubjectId(entityId); } else if ("subject".equalsIgnoreCase(entityType)) { int studySubId = discNoteUtil.getStudySubjectIdForDiscNote( discrepancyNoteBean, sm.getDataSource(), currentStudy.getId()); dispatcher = request.getRequestDispatcher( "/ViewStudySubject?id=" + studySubId + "&module=" + module); discrepancyNoteBean.setSubjectId(studySubId); } else if ("studyevent".equalsIgnoreCase(entityType)) { dispatcher = request.getRequestDispatcher("/EnterDataForStudyEvent?eventId=" + entityId); } // This code creates the URL for a popup window, which the // processing Servlet will initiate. // 'true' parameter means that ViewDiscrepancyNote is the // handling Servlet. createNoteURL = CreateDiscrepancyNoteServlet.getAddChildURL( discrepancyNoteBean, ResolutionStatus.CLOSED, true); request.setAttribute(POP_UP_URL, createNoteURL); try { if (dispatcher != null) { dispatcher.forward(request, response); } } catch (ServletException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } }
public void init(final ServletConfig sc) { try { super.init(sc); } catch (ServletException e) { e.printStackTrace(); } PersistenceUtils.init(sc); }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { try { doPost(request, response); } catch (ServletException e) { e.printStackTrace(); request.setAttribute("pushStatus", e.toString()); } }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { try { request.getRequestDispatcher("/jsp/welcome.jsp").forward(request, response); return; } catch (ServletException e) { e.printStackTrace(); } }
/** * 请求转发 * * @param url 转发地址 */ public void forward(String url) { try { this.request.getRequestDispatcher(url).forward(request, response); } catch (ServletException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
@SuppressWarnings("unchecked") @Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { List<String> errors = new ArrayList<String>(); PersistenceManager pm = getPersistenceManager(); String username = req.getParameter("username"); String password = req.getParameter("password"); if (username.isEmpty()) { errors.add("Username is required."); } if (password.isEmpty()) { errors.add("Password is required."); } try { req.setAttribute("errors", errors); List<Admin> us = (List<Admin>) pm.newQuery(Admin.class).execute(); resp.setContentType("text/html"); DatastoreService ds = DatastoreServiceFactory.getDatastoreService(); Query q = new Query("Admin"); q.setFilter( Query.CompositeFilterOperator.and( new Query.FilterPredicate("username", Query.FilterOperator.EQUAL, username), new Query.FilterPredicate("password", Query.FilterOperator.EQUAL, password))); List<Entity> entities = ds.prepare(q).asList(FetchOptions.Builder.withDefaults()); if (entities.size() == 0) { req.getRequestDispatcher("/login.jsp").forward(req, resp); } // if(entities.size()>0){ if (us.size() > 0) { /*for(int i = 0; i < us.size(); i++){ if(us.get(i).getPassword().equals(password) && us.get(i).getUsername().equals(username) && us.get(i).getUser_type() == 0){ resp.sendRedirect("/AdminHome"); } if(us.get(i).getPassword().equals(password) && us.get(i).getUsername().equals(username) && us.get(i).getUser_type() == 1){ resp.sendRedirect("/login.jsp"); } if(us.get(i).getPassword().equals(password) && us.get(i).getUsername().equals(username) && us.get(i).getUser_type() == 2){ resp.sendRedirect("/login.jsp"); } } //resp.sendRedirect("/login.jsp"); * */ // } } } catch (ServletException e) { e.printStackTrace(); } finally { pm.close(); } }
public void forward(HttpServletRequest request, HttpServletResponse respone) { request.setAttribute("redirectUrl", Constant.ROOT_URL + "loginController.do?login"); try { request.getRequestDispatcher("/webpage/common/loginTimeout.jsp").forward(request, respone); } catch (ServletException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
public Part part(String name) { try { return raw.getPart(name); } catch (IOException ex) { ex.printStackTrace(); return null; } catch (ServletException ex) { ex.printStackTrace(); return null; } }
/** sets to data the root tree */ public void setRootTree() { try { data = ModuleReferenceDataClientTreeData.select(conn, (lang.equals("") ? "en_US" : lang)); // addLinks(); setLevel(0); setIcons(); } catch (ServletException ex) { ex.printStackTrace(); data = null; } }
public Collection<Part> parts() { try { return raw.getParts(); } catch (IOException ex) { ex.printStackTrace(); return null; } catch (ServletException ex) { ex.printStackTrace(); return null; } }
private void SearchCompanyHandler(HttpServletRequest request, HttpServletResponse response) { try { forward("/CompanySearchForm.jsp", request, response); } catch (ServletException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private void EnableDisableHandler(HttpServletRequest request, HttpServletResponse response) { try { forward("/EnableDisable.jsp", request, response); } catch (ServletException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { String fowarding = "/guestbook"; RequestDispatcher rd = req.getRequestDispatcher(fowarding); try { rd.forward(req, resp); } catch (ServletException e) { e.printStackTrace(); } }
public void emit(ReplayParseContext context, Node node) throws IOException { String found = context.getData(FERRET_DONE_KEY); if (found == null) { context.putData(FERRET_DONE_KEY, "1"); try { super.emit(context, node); } catch (ServletException e) { e.printStackTrace(); throw new IOException(e.getMessage()); } } }
public void process(HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(); ServletContext app = getServletContext(); String lang = (String) app.getAttribute("MALL_LA"); System.out.println("langl: " + lang); try { final String reasonSelect = request.getParameter("reasonSelect"); final String reasonText = request.getParameter("reasonText"); final String orderDetailID = request.getParameter("orderDetailID"); // save cancel order if (orderDetailID != null) { TransactionMethod tr = new TransactionMethod() { @Override protected void doMethod(Session session, String lang) { Productorderdetail productorderdetail = ProductorderdetailBUS.getProductorderdetail( Integer.parseInt(orderDetailID), lang); System.out.println("lang: " + lang); // System.out.println("productorderdetail: // "+productorderdetail.getOrderDetailStatusId()); productorderdetail.setOrderDetailStatusId(ResourcesDefault.ODS_RETURN_EXCHANGE); // System.out.println("productorderdetail: // "+productorderdetail.getOrderDetailStatusId()); update(productorderdetail, session); Exchangeorder exchangeorder = new Exchangeorder(); exchangeorder.setMemoToSeller(reasonText); exchangeorder.setReason(reasonSelect); exchangeorder.setOrderDetail(productorderdetail); Exchangestatus exchangStatus = ExchangeStatusBUS.getExchangeStatus(1, lang); exchangeorder.setExchangeStatus(exchangStatus); exchangeorder.setRequiredDate(new Date()); save(exchangeorder, session); } }; System.out.println("langL " + lang); boolean result = tr.executeTransaction(lang); if (result) { request.setAttribute("sucessfull", "successfull"); } request.getRequestDispatcher("returnexchangesuccessfull.html").forward(request, response); } } catch (ServletException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
public void index(ServletRequest request, ServletResponse response) { try { request.setAttribute("page", "album"); request.getRequestDispatcher("pages/album.jsp").forward(request, response); } catch (ServletException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
private void getparms(HttpServletRequest request, HttpServletResponse response) { String dtname = request.getParameter("dtname"); Map<String, String> addressMap = new AppService().getparmsByDtname(dtname); try { request.setAttribute("addressMaps", addressMap); request.setAttribute("getDtNameofretparms", dtname); request.getRequestDispatcher("/admin/add_appparams.jsp").forward(request, response); } catch (ServletException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
/** 得到用户提交的应用审核 */ private void listbyuanme(HttpServletRequest request, HttpServletResponse response) throws SQLException { String uname = request.getParameter("myappuname"); try { List<Ckapp> ckapps = new CkappService().listbyuanme(uname); request.setAttribute("ckapps", ckapps); request.getRequestDispatcher("/index/core/myapplyapp.jsp").forward(request, response); } catch (ServletException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { handleRequest(request, response); } catch (ServletException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } }
private void dispatch( HttpServletRequest request, HttpServletResponse response, String callerPage, String msg) { try { request.setAttribute("signupMsg", msg); RequestDispatcher rd = request.getRequestDispatcher(callerPage); rd.forward(request, response); } catch (ServletException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
public void perform(HttpServletRequest req, HttpServletResponse res) { String deptids = req.getParameter("sendToGroup"); // String sendFrom = req.getParameter("sendFrom"); String sendTo = req.getParameter("sendTo"); String subject = req.getParameter("mainTitle"); String mailcontent = req.getParameter("textarea"); if (mailcontent == null) mailcontent = ""; if (sendTo == null) sendTo = ""; /* * System.out.println(deptids); System.out.println(sendFrom); * System.out.println(sendTo); System.out.println(subject); * System.out.println(mailcontent); */ try { // 设置发信 // 设置服务器 JavaMail themail = new JavaMail("127.0.0.1"); themail.setNeedAuth(true); if (themail.setSubject(subject) == false) { req.getRequestDispatcher("../error.jsp").forward(req, res); } // 邮件内容 支持html 如 <font color=red>欢迎光临</font> <a // href=\"http://www.laabc.com\">啦ABC</a> if (themail.setBody(mailcontent) == false) { req.getRequestDispatcher("../error.jsp").forward(req, res); } // 发件人邮箱 if (themail.setFrom("luolei@luoleiscomputer") == false) { req.getRequestDispatcher("../error.jsp").forward(req, res); } // 得到收信人list List<String> receivers = themail.getReceiverList(sendTo, deptids); for (int i = 0; i < receivers.size(); i++) { // 设置收件人邮箱 if (themail.setTo(receivers.get(i)) == false) { return; } themail.setNamePass("luolei", "luolei"); // 用户名与密码 if (themail.sendout() == false) { req.getRequestDispatcher("../error.jsp").forward(req, res); } } req.getRequestDispatcher("../success.jsp").forward(req, res); } catch (ServletException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private void getDtNameofparms(HttpServletRequest request, HttpServletResponse response) { List<String> accessedtables = new AppService().getDtnames(); try { request.setAttribute("getDtNameofretparms", accessedtables); request.getRequestDispatcher("/admin/add_appparams.jsp").forward(request, response); return; } catch (ServletException e) { e.printStackTrace(); return; } catch (IOException e) { e.printStackTrace(); return; } }
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { // String username = request.getParameter("username"); // String role = request.getParameter("role"); String username = "******"; String role = "student"; Group group = groupManager.getGroup(role); if (group == null) { group = new Group(); group.setName(role); groupManager.saveGroup(group); } User user = userManager.getUser(username); if (user == null) { user = new User(); user.setName(username); user.setPassword(Encryption.digest(DUMMY_PASSWORD, EncryptionType.MD5)); Set<Group> groups = new HashSet<>(); groups.add(group); user.setGroups(groups); userManager.saveUser(user); } request.logout(); StudentInformation newStudent = new StudentInformation(); newStudent.setUserName(username); newStudent.setPassword(Encryption.digest(DUMMY_PASSWORD, EncryptionType.MD5)); HttpSession currentSession = request.getSession(); currentSession.setAttribute("currentUser", newStudent); request.login(username, DUMMY_PASSWORD); String tos = termsOfServiceManager.getTermsOfServiceById(1).getTermsOfService(); currentSession.setAttribute("tos", tos); response.sendRedirect(request.getContextPath()); } catch (ServletException e) { e.printStackTrace(); request.getRequestDispatcher("/WEB-INF/login/login_error.jsp").forward(request, response); } }
private void crearDiccionario(HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(true); String divCrear = "1"; session.setAttribute("divCrear", divCrear); RequestDispatcher dispatcher = request.getRequestDispatcher("/DiccionarioList.jsp"); try { dispatcher.forward(request, response); } catch (ServletException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
public void generatePostPage( HttpServlet inServlet, HttpServletRequest inRequest, HttpServletResponse inResponse) { try { String wkSeason = inRequest.getParameter("season"); Document wkPageData = createPageDocument(wkSeason); XSLTRenderHelper.render(inServlet, wkPageData, "teamoverview.xsl", inResponse); } catch (ServletException wkEx) { wkEx.printStackTrace(); Email.emailException(wkEx); } catch (IOException wkEx) { wkEx.printStackTrace(); Email.emailException(wkEx); } }