aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Request Attribute doubt? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "Request Attribute doubt?" Watch "Request Attribute doubt?" New topic
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!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Request Attribute doubt?
 
Similar Threads
filters
Request parameter and Attribute??
get servlet name from ServletRequestAttribute Listener
query related to sessions
Request Attributes