0

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"); 

1 Answer 1

3

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);
Sign up to request clarification or add additional context in comments.

1 Comment

I've tried both of them alongwith response.redirect and jsp foward, but none of them works

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.