Storing Data for Later Use:
The Servlet Request
Purpose
Storing data that servlet looked up and that JSP page will 
use only in this request.
Servlet syntax to store data
SomeClass value = new SomeClass( );
request.setAttribute("key", value);
// Use RequestDispatcher to forward to JSP page
JSP syntax to retrieve data
id="key" 
class="SomeClass"
scope="request"
/>
109
JSP
www.corewebprogramming.com
Storing Data for Later Use:
The Session Object
Purpose
Storing data that servlet looked up and that JSP page will 
use in this request and in later requests from same client.
Servlet syntax to store data
SomeClass value = new SomeClass( );
HttpSession session = request.getSession(true);
session.setAttribute("key", value);
// Use RequestDispatcher to forward to JSP page
JSP syntax to retrieve data
id="key" 
class="SomeClass"
scope="session"
/>
110
JSP
www.corewebprogramming.com
55




  

Home

About Services Network Support FAQ Order Contact
 

Java Web Hosting

Our partners:Jsp Web Hosting Unlimited Web Hosting Cheapest Web Hosting  Java Web Hosting Web Templates Best Web Templates PHP Mysql Web Hosting Interland Web Hosting Cheap Web Hosting PHP Web Hosting Tomcat Web Hosting Quality Web Hosting Best Web Hosting  Mac Web Hosting 

Lunarwebhost.net  Business web hosting division of Vision Web Hosting Inc. All rights reserved