• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp can't get object from servlet using "getAttribute"  RSS feed

 
Ian Yang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello fellow,
I am using servlet 1.1 and jsp 1.0. In servlet,
I tried:
req.setAttribute(a, b);
res.sendRedirect("somejsp");
In somejsp:
Object o = request.getAttribute(a);
I didn't use "seeion.setAttribute" because I don't want session here. Now on the jsp side, the "request.getAttribute(a)" keeps returning null result. No compile error though. on jsp side, i also tried use
<jsp:useBean id="a" scope="request" class="..."/>
but same null result returns.
Should this work ? If not then maybe I have to use "forward(req, res)" to forward to jsp ?
Thanks,
ian
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when u use sendredirect u r sending the client to w new url witha new page etc...
he is having a new request there.
in order to pass the request as well to the new page u need to use the forward like u said.
 
Ian Yang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roy,
Tahnk you so much !!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!