0

I have two servlet ReplayFilter and VideoReplayServlet. From ReplayFilter, I am calling VideoReplayServlet using chain.doFilter. I am able to call VideoReplayServlet from ReplayFilter but I am not able to get userId variable from request object in VideoReplayServlet, which I have already set in request object before calling chain.doFilter. You can find my code below -

In ReplayFilter -

   request.setAttribute("userId", userId);
   request.setAttribute("uname", "mari");

chain.doFilter(request, response);

In VideoReplayServlet -

  String uname = request.getParameter("uname");
  String user_Id = request.getParameter("userId");

In VideoReplayServlet replay, I am getting both uname and user_Id null.

Can anybody help me?

Bhavin Bhadani
  • 22,224
  • 10
  • 78
  • 108
Abhishek
  • 315
  • 5
  • 18
  • Please post your `web.xml` file along with the code for the two methods in each servlet. – Tim Biegeleisen Aug 28 '15 at 06:40
  • Interesting difference between getAttribute and getParameter http://stackoverflow.com/questions/5243754/difference-between-getattribute-and-getparameter – Weslor Aug 28 '15 at 07:03

1 Answers1

1

I think the issue here is that you are setting it as an attribute and expecting it as a parameter which is contradicting. Try the below code instead

request.getAttribute("userId", userId); //Note the getAttribute() instead of getParameter()
Balaji Katika
  • 2,835
  • 2
  • 21
  • 19