Reputation: 7967
I have to pass parametrs From servlet to jsp .Iam using the following code.Is it possible to pass parameters through this way?
String val="Testvalue"
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/index.jsp?valpass=val");
dispatcher.forward(request, response);
In jsp
String value=(String)request.getAttribute("valpass")
^
Upvotes: 3
Views: 6890
Reputation: 240946
if you forward from servlet
to jsp you should set as attribute
do
request.setAttribute("key","value")
parameter is mainly used in communicating with client to server. and use attribute as internal message passing
Upvotes: 4