Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2006

Tip: Looking for answers? Try searching our database.

create a bean on webapp startup

Thread view: 
Mounir AITTAHAR - 14 Aug 2006 10:45 GMT
Hi,

Unsuccessfully web browsing makes me come here.

I wonder if it's possible to create a bean (used by <jsp:use-bean>) on
startup, also through web.xml. I've seen it is possible to launch a
servlet with <load-on-startup> xml element, but, as I believe I've
understood, it is NOT a persistent object.

So, i'm asking if :
- is this possible to create a persistent object through a servlet
lauched at startup ?
- is there a different way ?

Regards,

Signature

Mounir

Mounir - 14 Aug 2006 16:00 GMT
Hi all,

It was very simple : I've created the bean through a loaded-on-startup
servlet, and added to the servlet context :

web.xml :
<servlet>
<servlet-name>aServlet</servlet-name>
<servlet-class>package.of.the.servlet.aServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<servlet>

Source part of aServlet.init():
{
 ServletContext context=getServletContext();
 context.setAttribute("beaname",beanobjet);
}

And in jsp files :

<jsp:use-bean id="beaname" scope="application
class="package.of.the.bean.BeanObject"
type="package.of.the.bean.BeanObject"/>

(type is optionnal here)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.