List of usage examples for javax.servlet.http HttpServletRequest setCharacterEncoding
public void setCharacterEncoding(String env) throws UnsupportedEncodingException;
From source file:com.ecyrd.jspwiki.url.SilverpeasURLConstructor.java
/** * Should parse the "page" parameter from the actual request. {@inheritDoc} *//*from w w w . j a va 2 s .co m*/ public String parsePage(String context, HttpServletRequest request, String encoding) throws UnsupportedEncodingException { request.setCharacterEncoding(encoding); String pagereq = request.getParameter("page"); if (context.equals(WikiContext.ATTACH)) { pagereq = parsePageFromURL(request, encoding); } return pagereq; }
From source file:psiprobe.ProbeServlet.java
/** * Dispatch.// w w w. ja v a2 s . co m * * @param httpServletRequest the request * @param httpServletResponse the response * @throws Exception if setting UTF-8 encoding fails or if the super implementation throws an * exception */ @Override protected void doDispatch(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { httpServletRequest.setCharacterEncoding(StandardCharsets.UTF_8.name()); super.doDispatch(httpServletRequest, httpServletResponse); }
From source file:com.trsvax.jacquard.services.EMultipartDecoderImpl.java
public HttpServletRequest decode(HttpServletRequest request) { try {//from w ww. j av a 2 s .c om request.setCharacterEncoding(requestEncoding); } catch (UnsupportedEncodingException ex) { throw new RuntimeException(ex); } List<FileItem> fileItems = parseRequest(request); return processFileItems(request, fileItems); }
From source file:com.wibidata.shopping.servlet.CreateUserServlet.java
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { request.setCharacterEncoding("UTF-8"); request.getRequestDispatcher("/WEB-INF/view/CreateUser.jsp").forward(request, response); }
From source file:org.siphon.db2js.DispatchServlet.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); DbjsRunner dbjsRunner = this.getDbjsRunner(); dbjsRunner.run(request, response, StringUtils.defaultIfEmpty(request.getParameter("_m"), "fetch")); }
From source file:org.siphon.db2js.DispatchServlet.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); DbjsRunner dbjsRunner = this.getDbjsRunner(); dbjsRunner.run(request, response, StringUtils.defaultIfEmpty(request.getParameter("_m"), "create")); }
From source file:org.jbpm.designer.web.server.FormWidgetServlet.java
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding("UTF-8"); String profileName = Utils.getDefaultProfileName(req.getParameter("profile")); String action = req.getParameter("action"); String widgetName = req.getParameter("widgetname"); String uuid = Utils.getUUID(req); if (profile == null) { profile = _profileService.findProfile(req, profileName); }/*from ww w . ja va 2s .co m*/ Repository repository = profile.getRepository(); if (action != null && action.equals("getwidgets")) { List<String> widgetList; try { widgetList = ServletUtil.getFormWidgetList(profile, repository, uuid); } catch (Throwable t) { widgetList = new ArrayList<String>(); } JSONObject jsonObject = new JSONObject(); if (widgetList != null && widgetList.size() > 0) { for (String widget : widgetList) { try { jsonObject.put(widget, widget); } catch (Exception e) { e.printStackTrace(); } } } resp.setCharacterEncoding("UTF-8"); resp.setContentType("application/json"); resp.getWriter().write(jsonObject.toString()); } else if (action != null && action.equals("getwidgetsource")) { try { Asset<String> widgetAsset = repository .loadAssetFromPath(profile.getRepositoryGlobalDir(uuid) + "/" + widgetName + ".fw"); resp.setCharacterEncoding("UTF-8"); resp.setContentType("text/plain"); resp.getWriter().write(widgetAsset.getAssetContent()); } catch (Exception e) { resp.getWriter().write(""); } } }
From source file:com.delmar.core.web.filter.ExportFilter.java
/** * {@inheritDoc}/*from w w w. ja v a 2 s . co m*/ */ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; request.setCharacterEncoding(endcoding); if (servletRequest.getParameter(TableTagParameters.PARAMETER_EXPORTING) == null) { if (log.isDebugEnabled()) { log.debug(Messages.getString("ResponseOverrideFilter.parameternotfound")); //$NON-NLS-1$ } // don't filter! filterChain.doFilter(servletRequest, servletResponse); return; } BufferedResponseWrapper wrapper = new BufferedResponseWrapper13Impl((HttpServletResponse) servletResponse); Map contentBean = new HashMap(4); if (buffer) { contentBean.put(TableTagParameters.BEAN_BUFFER, Boolean.TRUE); } request.setAttribute(TableTag.FILTER_CONTENT_OVERRIDE_BODY, contentBean); filterChain.doFilter(request, wrapper); ExportDelegate.writeExport((HttpServletResponse) servletResponse, servletRequest, wrapper); }
From source file:ua.aits.crc.controller.MainController.java
@RequestMapping(value = { "/sendmail/", "/sendmail" }, method = RequestMethod.GET) public @ResponseBody String sendMail(HttpServletRequest request, HttpServletResponse response) throws Exception { request.setCharacterEncoding("UTF-8"); String name = request.getParameter("name"); String email = request.getParameter("email"); String text = request.getParameter("text"); final String username = "office@crc.org.ua"; final String password = "crossroad2000"; Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.port", "587"); Session session = Session.getInstance(props, new javax.mail.Authenticator() { protected javax.mail.PasswordAuthentication getPasswordAuthentication() { return new javax.mail.PasswordAuthentication(username, password); }// w w w . j a va 2 s.c om }); try { Message message = new MimeMessage(session); message.setFrom(new InternetAddress(email)); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("office@crc.org.ua")); message.setSubject("Mail from site"); message.setText("Name: " + name + "\nEmail: " + email + "\n\n" + text); Transport.send(message); return "done"; } catch (MessagingException e) { throw new RuntimeException(e); } }
From source file:com.slience.controller.AuthController.java
@RequestMapping("role/delete/{id}") @ResponseBody/*from w ww . j av a 2s .c o m*/ public Map<String, ?> handRoleDeleteRequest(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") String id) throws Exception { request.setCharacterEncoding("UTF-8"); response.setContentType("application/json;charset=UTF-8"); return null; }