• Post Reply Bookmark Topic Watch Topic
  • New Topic

Loading at statrtUp  RSS feed

 
Ahmed Shaikh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am working on web based project I which using Servlet,JSP and RMI.
I am facing some problem in it So, plz help me in solving it.
Problem is that:-
1.I have one .java file which is calling a .properties file ,I want to Load this .java file when first application is started so we don't have to load it again and again.
2.There is one .java file which work as Registry So,this file will invoke only when Admin login.so plz tell where i have to put this files so it will fullfill my task .

Thanx in advance .
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding point 1, read up on the <load-on-startup> element of the web.xml file. It lets you specify a servlet to be run on startup which can initialize things for you.
Regarding point 2, it sounds like some sort of access control is needed. Using the security-constraint, login-config and security-role elements of web.xml you can specify who has access to which URLs of your web app. You also have to configure a realm in Tomcat; an easy way of doing that is described here.
[ August 29, 2005: Message edited by: Ulf Dittmer ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using a servlet spec 2.3 or greater compliant container, you could also use a Context Listener.

The contextInitialized method will be called before any servlets get loaded.
One advantage is that you don't need to keep track of all of your load-on-startup configurations to make sure that one servlet doesn't load without the required values from another.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!