Request attributes only last the life of one request.A "request" is asking the server for one URLThe "response" is what the server sends back.So every click of a link, every form submission, every image downloaded - each of them is a seperate request.You are sending two different requests1 - load page with initial form (ie Send.jsp) (setting request attribute)2 - load page with result ( /Receive ) (trying to retrieve request attribute)Because you have two seperate requests, you can't use request attributes to pass data, and have to use session.If you use RequestDispatcher or
request.setAttribute versus session.setAttribute:
My understanding is that request.setAttribute only make the key available in the following jsp page. But session.setAttribute will make the key available in many pages, as long as in the same session, and browser not close.For example, the flow like page1->page2->page3->page4. session.setAttribute will make the key available in all pages. But if we use request.setAttribute in page2, then only page3 can get the key value set in page2.
Tuesday, July 17, 2007
To pass more then one request from jsp page to java servlet
Posted by Prem Kumar Jha at 11:29:00 AM 0 comments
Subscribe to:
Posts (Atom)