• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request Attribute doubt?

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

Why is that if I set a request attribute in a jsp and do a form action to a servlet and in the servlet, I'm unable to retrieve the request attribute??
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It gave me a NullPointerException in my servlet!
 
Mark Garland
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are doing a form action, this is requiring the client to make a NEW request to the server.

Instead, if you used <jsp:include> or <jsp:forward> (i.e. you are request dispatching instead), then the request object will be reused and your attribute will be there.

It's a lot the same as redirect vs. dispatch. The top one makes the client make the redirect by making a new request. The bottom one is doing things server side, and using the same request object.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it Mark!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic