Sasi Kumar M
Sasi Kumar M

Reputation: 2630

Request.getAttribute is not working in jsp

I am setting attribute inside form tag in jsp like this.

            request.setAttribute("iTDay", 5);

I am trying to retrieve the value as

             System.out.println( request.getAttribute("iTDay"));

in another jsp page. Simple but its not working. Kindly suggest.

Thanks in advance.

Upvotes: 2

Views: 7061

Answers (1)

c.pramod
c.pramod

Reputation: 606

Unless you store the attribute in a session or redirect to the another page along with the attribute you cant retrieve the set attribute from one page to the another .

try

request.getSession().setAttribute("iTDay", 5);

System.out.println( request.getSession().getAttribute("iTDay"));

instead !

Upvotes: 4

Related Questions