JavaServer Pages
In order to simplify website developement and maintenance, a multideveloper approach requires that a developer never place Java programming code in a JSP page. The page should only contain HTML, (or XHTML or XML), JavaBeans and /or JSP tag libaries.
You can write declarations in two ways: JSP syntax or XML syntax. JSP Syntax < %! int index = 10 ; % > or XML Syntax < jsp:declaration >int index = 10 ; < /jsp:declaration > One Important point to notice is that a semicolon (;) terminates these declarations. The semicolon is necessary, becaue the declarations must be complete legal statements.
Free objects that the JSP container provides, which encapsulate specific concepts related to web applications, they provide access to JSP's runtime environment.(i.e. _jspService() method) The first level is page scope which is restricted to a single JSP page. Any object that is created with page scope is only accessible within the page where it is created. Once the HTTP response has been sent to the requesting client or the original HTTP request has been forwarded to another web component. all references to objects with page scope are released and the objects become candidates for garbage collection. (Garbage collection is when the system destroys unused objects, thus removing them from memory. Request scope refers to all processing need to satisfy a single HTTP request. For example, if a website requires you to log in, you might interact with multiple JSP pages. Your request will probably be processed by a controlling Servlet, the data stored in multiple JavaBeans, and a JSP page will present the results to the client(usually a web browser.) Objects with request scope are valid until the requst has been completed. This means objects with request scope, that are stored in the request object, can be shared among multiple JSP pages.
Request object stores those objects that have request scope. This is accomplished by request attributes. The ServletRequest class has setAttribute() and getAttribute() methods, which allow you to associate any Java object to a name, so the object can be shared between different JSP pages that are participating in handling a particular request.
Anytime you fill out a form on a website and click submit, your browser transfers the information to the server as parameters. The two mechanisms for sending this information are the HTTP GET and the HTTP PUT operations
You can associate objects with a HTTP session, which allows different requests to share information. Objects with session scope are valid until throughout the duration of a session.
In order to share information between sessions, you can use the application object which provides a higher level of application scope and enables different sessions to share data or objects.
|