0

I need to recieve some data from a jsp file in java servlet,do some stuff and after that send data to another jsp.How can I do that? I tried response.sendredirect() but it's not working at all.

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
   //recieve some parameters from request
   String c=request.getParameter("column");
   //do stuff
   //I need to send board which is int[][]
   request.setAttribute("board",board);
   RequestDispatcher rd = request.getRequestDispatcher("/redirect.jsp");
   rd.forward(request, response);
   }
Noname
  • 41
  • 1
  • 1
  • 10
  • "from java" ? or do you mean to say from a Servlet? – rickz May 26 '16 at 17:24
  • yes,I mean from Servlet – Noname May 26 '16 at 17:27
  • If you need to get a response from a JSP within a Servlet, then you can use a HttpURLConnection object. – rickz May 26 '16 at 17:37
  • I managed the part to get response,I can't redirect and send data – Noname May 26 '16 at 18:20
  • You will need to post more details or more code in order for us to help you. Also, you say "redirect" but in your code you have a forward( rd.forward()). Which is it? – rickz May 26 '16 at 18:52
  • I said that I tried to use redirect and nothing happened so I tried with requestdispatcher – Noname May 26 '16 at 20:51
  • I think you should first follow the link provided: [Difference between Request Dispatcher Forward and Response.sendRedirect](http://stackoverflow.com/questions/7220241/whats-the-difference-between-requestdispatcher-forward-and-httpservletrespons) – Jasmine May 31 '16 at 18:37

0 Answers0