Example usage for javax.servlet.http HttpServletRequest setCharacterEncoding

List of usage examples for javax.servlet.http HttpServletRequest setCharacterEncoding

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest setCharacterEncoding.

Prototype

public void setCharacterEncoding(String env) throws UnsupportedEncodingException;

Source Link

Document

Overrides the name of the character encoding used in the body of this request.

Usage

From source file:flexus.web.servlet.APListServlet.java

/**
 * {@inheritDoc}/*from w  ww.  j  a  v  a 2 s .c  o  m*/
 */
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    request.setCharacterEncoding("utf-8");
    response.setContentType("text/xml");
    response.setCharacterEncoding("utf-8");

    InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("aps.xml");

    if (stream != null) {
        try {
            String apDoc = IOUtils.toString(stream, "UTF-8");
            if (apDoc != null && apDoc.trim().length() > 0) {
                response.getWriter().write(apDoc);
            }
        } finally {
            response.getWriter().flush();
            IOUtils.closeQuietly(stream);
        }
    }
}

From source file:edu.cornell.mannlib.vitro.webapp.filters.CharsetEncodingFilter.java

private void setCharacterEncodingOnRequest(HttpServletRequest req) throws UnsupportedEncodingException {
    if (!ServletFileUpload.isMultipartContent(req)) {
        req.setCharacterEncoding("UTF-8");
    }//from   w  ww . j  a v  a2  s  .  co  m
}

From source file:net.sf.jooreports.web.spring.controller.AbstractDocumentGenerator.java

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    request.setCharacterEncoding("UTF-8");
    renderDocument(getModel(request), request, response);
    return null;//from   w  w w .  j av a 2s .  c o  m
}

From source file:com.sbu.controller.Feed_Personal_Startup_View_Controller.java

protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    request.setCharacterEncoding("UTF-8");

    Startup User = new Startup();

    List<Member1> members = new ArrayList();
    int counter = 1;

    HttpSession session = request.getSession();

    User = (Startup) request.getSession().getAttribute("User");
    //members= (ArrayList<Member1>) request.getSession().getAttribute("members");
    members = memberService.getMemberByStartupId(User.getIdStartup());

    session.setAttribute("SearchQueries", User);
    session.setAttribute("members", members);
    session.setAttribute("counter", counter);

    //request.getRequestDispatcher("EmployeeTest.jsp").forward(request, response);
    request.getRequestDispatcher("/Personal_Startup.jsp").forward(request, response);

}

From source file:flexus.web.servlet.StartMenusServlet.java

/**
 * @param request/*from   w w w .j  a v a2  s. co m*/
 * @param response
 */
private void doProcess(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    request.setCharacterEncoding(charsetName);
    response.setCharacterEncoding(charsetName);

    InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("startMenus.xml");
    byte[] bytes = null;
    if (stream != null && stream.available() > 0) {
        bytes = IOUtils.toByteArray(stream);
    }

    response.setContentType("text/xml");

    if (bytes != null) {
        response.getOutputStream().write(bytes);
        response.getOutputStream().flush();
    }
}

From source file:com.sishistorico.sv.SvExcluirEleitor.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*from w w w  .j  a  v a2 s  . c  o  m*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    request.setCharacterEncoding("UTF8");
    response.setContentType("text/html;charset=UTF-8");
    int id = Integer.parseInt(request.getParameter("id"));

    DaoEleitor daoEleitor;
    DaoFoto foto;
    try {
        daoEleitor = new DaoEleitor();
        foto = new DaoFoto();
        daoEleitor.Eleitor_Excluir(id);
        foto.ExcluirImagem(id);
        response.getOutputStream().print("Deletado com Sucesso!");

    } catch (SQLException ex) {
        Logger.getLogger(SvExcluirEleitor.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(SvExcluirEleitor.class.getName()).log(Level.SEVERE, null, ex);
    } catch (Exception ex) {
        Logger.getLogger(SvExcluirEleitor.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:org.siphon.db2js.DispatchServlet.java

@Override
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    req.setCharacterEncoding("utf-8");
    DbjsRunner dbjsRunner = this.getDbjsRunner();
    dbjsRunner.run(req, resp, "delete");
}

From source file:org.siphon.db2js.DispatchServlet.java

@Override
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    req.setCharacterEncoding("utf-8");
    DbjsRunner dbjsRunner = this.getDbjsRunner();
    dbjsRunner.run(req, resp, "modify");
}

From source file:com.wibidata.shopping.servlet.SignInServlet.java

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    request.setCharacterEncoding("UTF-8");
    request.getRequestDispatcher("/WEB-INF/view/SignIn.jsp").forward(request, response);
}

From source file:ilarkesto.gwt.server.AUploadServlet.java

@Override
protected final void doPost(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    request.setCharacterEncoding(IO.UTF_8);
    super.doPost(request, response);
}