| Author |
Request Attribute doubt?
|
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
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??
|
SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
|
It gave me a NullPointerException in my servlet!
|
 |
Mark Garland
Ranch Hand
Joined: Nov 11, 2006
Posts: 226
|
|
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.
|
28/06/06 - SCJP - 69%, 05/06/07 - SCWCD - 92%, 28/02/08 - IBM DB2 v9 Fundamentals (Exam 730) - 87%, 18/11/08 - IBM DB2 v9 DBA (Exam 731) - 89%, 26/02/11 - SCBCD - 88%
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
Got it Mark!
|
 |
 |
|
|
subject: Request Attribute doubt?
|
|
|