The document discusses implicit objects in JSPs including session objects, which allow storing and retrieving data across multiple requests and pages; it provides an example using session objects to pass numbers entered on one page to another page to display the numbers and perform operations on them; the example demonstrates setting attributes in the session on one page and retrieving them on another page to pass data between pages using the session.
The document discusses implicit objects in JSPs including session objects, which allow storing and retrieving data across multiple requests and pages; it provides an example using session objects to pass numbers entered on one page to another page to display the numbers and perform operations on them; the example demonstrates setting attributes in the session on one page and retrieving them on another page to pass data between pages using the session.
The document discusses implicit objects in JSPs including session objects, which allow storing and retrieving data across multiple requests and pages; it provides an example using session objects to pass numbers entered on one page to another page to display the numbers and perform operations on them; the example demonstrates setting attributes in the session on one page and retrieving them on another page to pass data between pages using the session.
JSP Container makes certain JAVA Objects available on
JSP. These objects are called Implicit objects.
Implicit objects need not to be declared, defined or
instantiated like other JAVA Objects.
One example is the session Object which is defined for
you and you can start using it in your jsp. HttpSession HttpSession objects live on the server; they're just automatically associated with the requester by a behind-the-scenes mechanism like cookies or URL-rewriting. These session objects have a builtin data structure that let you store any number of keys and associated value Example ** In this example we will take 2 numbers in the file session_001.jsp ** in session_002 we will add them to a session and take a name ** In ShowNumbesSession.jsp we will retrieve the numbers from the session and the name from the parameters and display them <%-- Document : session_001 Created on : Aug 11, 2013, 4:17:32 PM Author : ehab --%>
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1256"> <title>JSP Page</title> </head> <body> <%= request.getParameter("name") %> <br> <% int s = (Integer) session.getAttribute("start"); // must cast to int int f = (Integer) session.getAttribute("finish"); for(int i=s; i<=f; i++){ out.print(i+ " - "); } %> </body> </html> Run session_001 Assignment # 2
Modify the mlutiplication table given in
assignment # 1 to take the start and end parmateers and put them into a session and take a title and display athe title above the multiplication table. Must use setAttribute nad get atttribute for the start and finish..