Problem with sending value of variable with RequestDispatcher
In variable search_for I've got the string value of the value I'm searching开发者_如何转开发 for. But I cannot pass it via RequestDispatcher to jsp. What am I doing wrong?
RequestDispatcher rd = request.getRequestDispatcher("my.jsp?search_for");
Soution 1 :
request.setAttribute("paramName", search_for);
RequestDispatcher rd = request.getRequestDispatcher("my.jsp");
rd.forward(request, response);
or
Soution 2 :
RequestDispatcher rd = request.getRequestDispatcher("my.jsp?paramName="+search_for);
rd.forward(request, response);
精彩评论