harpal18
harpal18

Reputation: 135

Why can't i pass map from jsp to Servlet

I want to pass a Map<String,Object> from jsp page to servlet. I have tried with c:set value="${map} scope="request"> and also with scriplet <%request.setAttribute("map",map)%> but when i try to retrieve map from servlet it always gives null ?

Upvotes: 0

Views: 568

Answers (1)

Ali Sepehri.Kh
Ali Sepehri.Kh

Reputation: 2508

You are using submit button to trigger your servlet class. When you press submit button a new request object is created and it will not contain your map object.

To resolve this problem you can use session object instead of request object.

Note: Same request object transfer through jsp page to servlet class when you used forward method through them. Pay attention that in your case that is not possible in normal way; because you want to get some info from user and submit button will send them to servlet.

Upvotes: 1

Related Questions