The problem is as follows. There are two pages - main.jsp and books.jsp and the search form. When searching with books (GET method) everything is fine. When searching with main (if the search_str parameter came to the url), I do a response.sendRedirect(String url) on the books, specifying the address and search parameters that came in the request. But according to the result, the parameter does not come to books.jsp, for example, "books.jsp? Search_str = smith ", but "books.jsp? Search_str = A <8B ". That is, Russian characters come in a different encoding.

 <%request.setCharacterEncoding("UTF-8");%> <%response.setCharacterEncoding("UTF-8");%> 

did not help. What to do to properly transfer the parameters when redirecting?

  • Try this: response.sendRedirect(java.net.URLEncoder.encode("index?name=Русский язык")); Took from here - MrFylypenko
  • did not pass, but I suspect that I somehow did not prescribe the address. well, plus the deprecated method. but almost synchronously with you I came across a solution to my problem here . a redirect through the getServletContext getServletContext().getRequestDispatcher("/pages/books.jsp").forward(request,response); - gnoomqw6

1 answer 1

the redirect via the getServletContext getServletContext().getRequestDispatcher("/pages/books.jsp")‌​.forward(request,res‌​ponse);