• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Accessing Implicit objects in jspinit()

 
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am aware of the fact that the implicit objects, viz. application, session, request, response, etc. are not available until the service() (or jsp_service() method) is called.
In that case, how do I go about initializing/configuring a servlet with some object instances for the other servlets in the web application to use.My requirement is to have start-up servlet which is configured with a name/value pair for an object of class Information.This class would contain the name of the webmaster, his address and other details.
I guess, the only way to do it is using the ServletConfig class.But does it allow us to store customized objects instances of class like Information?I would not like to store it as web_master_name=sandeep,address=some_address, etc., as there are many such name/value pairs
I could have used the setAttribute("Information", i) with any of the implicit objects in the jspinit() (or init()) method, had any of these objects been available.
Please advise a workaround for this.
Thanks in advance.
Regards
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56

  5. [This message has been edited by Desai Sandeep (edited April 26, 2001).]
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have access to the servlet context (application) in jspInit() because the JspPage interface extends javax.servlet.Servlet, which has the getServletConfig() method:

Additionally, you can specify context parameters in the web.xml file with <context-param>...</context-param>. See the JSP spec or the webapp DTD for details.
------------------
Phil Hanna
Sun Certified Programmer for the Java 2 Platform
Author of :
JSP: The Complete Reference
Instant Java Servlets
Website: http://www.philhanna.com
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Phil,
Thanks very much for the response and the code
------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you would like to use web.xml method, here is a sample code.
http://www.javaranch.com/ubb/Forum7/HTML/003152.html
regds
maha anna
 
reply
    Bookmark Topic Watch Topic
  • New Topic