Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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

 
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
 
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The point is that sendRedirect sends a message back to the browser and the browser creates a NEW request to a new URL - which could be to an entirely different system.
You are correct that forward keeps the same request object so you can store an object in it.
Bill
 
Ian Yang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much William !!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!