Java
  Home arrow Java arrow Page 2 - JavaServer Pages, conclusion
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

JavaServer Pages, conclusion
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 2 stars2 stars2 stars2 stars2 stars / 5
    2005-11-10

    Table of Contents:
  • JavaServer Pages, conclusion
  • The config Object
  • Try It Out: Using JavaBeans in JSP Pages
  • Translation and Compilation
  • The Deployment Descriptor
  • Including and Forwarding from JSP Pages
  • Summary

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    JavaServer Pages, conclusion - The config Object


    (Page 2 of 7 )

    This object is used to obtain JSP-specific init parameters. These initialization parameters are set in the deployment descriptor, but are specific to a single page. JSP init parameters are set in the <servlet> element of the deployment descriptor. This is because the page implementation class of the JSP (the Java class which is compiled from the JSP page) is a servlet class. The <servlet> element with the <init-param> element will look like this:

      <servlet>
        <servlet-name>StockList</servlet-name>
        <servlet-class>web.StockListServlet</servlet-class>
       <init-param>
          <param-name>name</param-name>
          <param-value>value</param-value>
        </init-param>
      </servlet>

    See Chapter 5 for more information on how to use the <servlet> element.

    If JSP initialization parameters are defined in the deployment descriptor, you can access them using:

    config.getInitParameter(String name);

    The exception Object

    This implicit object is only available within error pages. It is a reference to the java.lang.Throwable object that caused the server to call the error page.

    The application Object

    This object represents the web application environment. You will use this object to get application-level configuration parameters. Within the deployment descriptor, you can set application parameters using this element:

      <webapp>
       
    <context-param>
          <param-name>name</param-name>
          <param-value>value</param-value>
       
    </context-param>
      </webapp>

    The value of the parameter can be accessed using:

      application.getInitParameter(String name);

    Scope

    Objects that are created as part of a JSP have a certain scope, or lifetime. That scope varies with the object. In some cases, such as the implicit objects, the scope is set and cannot be changed. With other objects (JavaBeans for example), you can set the scope of the object. Valid scopes are page, request, session, and application.

    • page Page scope is the most restrictive. With page scope, the object is only accessible within the page in which it is defined. JavaBeans created with page scope and objects created by scriptlets are thread-safe. (Recall, though, that Java objects created by declaration elements are not thread-safe.)
    • request With request scope, objects are available for the life of the specific request. This means that the object is available within the page in which it is created, and within pages to which the request is forwarded or included. Objects with request scope are thread-safe. Only the execution thread for a particular request can access these objects.
    • session Objects with session scope are available to all application components that participate in the clients session. These objects are not thread-safe. If multiple requests could use the same session object at the same time, you must synchronize access to that object.
    • applicationThis is the least restrictive scope. Objects that are created with application scope are available to the entire application for the life of the application. These objects are not thread-safe and access to them must be synchronized if there is a chance that multiple requests will attempt to change the object at the same time.

       

    More Java Articles
    More By Apress Publishing


       · This article is an excerpt from the book "Beginning J2EE 1.4 From Novice to...
     

    Buy this book now. This article is excerpted from chapter three of Beginning J2EE 1.4 From Novice to Professional, written by James L. Weaver, Kevin Mukhar, and Jim Crume (Apress, 2004; ISBN: 1590593413). Check it out at your favorite bookstore today. Buy this book now.

    JAVA ARTICLES

    - Deploying Multiple Java Applets as One
    - Deploying Java Applets
    - Understanding Deployment Frameworks
    - Database Programming in Java Using JDBC
    - Extension Interfaces and SAX
    - Entities, Handlers and SAX
    - Advanced SAX
    - Conversions and Java Print Streams
    - Formatters and Java Print Streams
    - Java Print Streams
    - Wildcards, Arrays, and Generics in Java
    - Wildcards and Generic Methods in Java
    - Finishing the Project: Java Web Development ...
    - Generics and Limitations in Java
    - Getting Started with Java Web Development in...






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT