Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot Preload Servlet - How to

 
Raj Mohan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!.
Any body help me in the following problem.
I have an online catalog in Java servlets. To run this catalog, I have to preload one servlet. But I don't have any web servers.
I am using JSDK 2.1 -Startserver & stopserver things. Is there any way to preload servlets in JSDK.
OR
Do have to load an web server?. In that case, please mention the smallest size file servlet and where to get it.
Many thanks.
Raj
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using JSDK? I think the last time that was
updated was in late 1999. Sun turned over all of that development to the Apache organization. The Tomcat server is where current development is occurring.
In Tomcat you can specify that a servlet will be loaded on startup.
There are also other servlet engines with free development downloads that are better documented than the old JSDK.
Look at www.orionserver.com for instance.
Bill
 
knex knex
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this in your web.xml
<servlet>
<servlet-name>
startup_servlet
</servlet-name>
<servlet-class>
PATH.StartupServ
</servlet-class>
<load-on-startup>
1 <-----------------priority
</load-on-startup>
</servlet>
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
knex...

Have you tried this <load-on-startup> tag for any J2EE apps? We are trying to figure out how to get an enterprise application to load some classes on startup... if we could get a servlet to start up though, perhaps we can write a small utility servlet to poke some EJB's.

In any case, thanks for giving me hope.
 
vikinsa
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!,
If you are using only the JSDK any version you can still be able to preload the servlet. Do one thing aupdate the classpath of your system and make sure that the classpath has the path of the class file of that servlet.
try appending like this..
c:\<servlet-directory>\<servlet-name>.class

Originally posted by Raj Mohan:
Hi!.
Any body help me in the following problem.
I have an online catalog in Java servlets. To run this catalog, I have to preload one servlet. But I don't have any web servers.
I am using JSDK 2.1 -Startserver & stopserver things. Is there any way to preload servlets in JSDK.
OR
Do have to load an web server?. In that case, please mention the smallest size file servlet and where to get it.
Many thanks.
Raj


------------------
Vikas Aggarwal
Technology Associate
http://www.vikinsa.com
 
Michael OConnor
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried getting the load
on startup tag working in my web.xml
but to no avail.
Here is my line,
<servlet>
<servlet-name>
TrapReceiver.class
</servlet-name>
<servlet-class>
TrapReceiver
</servlet-class>
<load-on-startup>5</load-on-startup>
</servlet>
I've tried using priorty 1 also,
My servlet log just says
2001-07-10 02:50:05 - path="/examples" :jsp: init
2001-07-10 02:50:05 - path="/datacenter" :jsp: init
2001-07-10 02:50:05 - path="/admin" :jsp: init
And when i start tomcat the error i get is :
cannot load servlet name: TrapReceiver.class
The TrapReciever.class file is located in C:\tomcat\webapps\examples\WEB-INF\classes
I've tried <servlet-class>
TrapReceiver.class
& also/webapps/examples/WEB-INF/classes/TrapReceiver.class
</servlet-class>
But to no avail
Can anyone shed any light on this ??
 
Cherry Mathew
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Michael OConnor:
I have tried getting the load
on startup tag working in my web.xml
but to no avail.
Here is my line,
<servlet>
<servlet-name>
TrapReceiver.class
</servlet-name>
<servlet-class>
TrapReceiver
</servlet-class>
<load-on-startup>5</load-on-startup>
</servlet>
I've tried using priorty 1 also,
My servlet log just says
2001-07-10 02:50:05 - path="/examples" :jsp: init
2001-07-10 02:50:05 - path="/datacenter" :jsp: init
2001-07-10 02:50:05 - path="/admin" :jsp: init
And when i start tomcat the error i get is :
cannot load servlet name: TrapReceiver.class
The TrapReciever.class file is located in C:\tomcat\webapps\examples\WEB-INF\classes
I've tried <servlet-class>
TrapReceiver.class
& also/webapps/examples/WEB-INF/classes/TrapReceiver.class
</servlet-class>
But to no avail
Can anyone shed any light on this ??

Hi Michael,
Where did u put u r web.xml file?. If its not in the /example/web-inf/web.xml then paste u r <servlet> tag there. And it should work.
I think tomcat is more comfortable if u use the packages for all the classes u use.
Hope this will help u
Cherry
 
Cherry Mathew
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Michael OConnor:
I have tried getting the load
on startup tag working in my web.xml
but to no avail.
Here is my line,
<servlet>
<servlet-name>
TrapReceiver.class
</servlet-name>
<servlet-class>
TrapReceiver
</servlet-class>
<load-on-startup>5</load-on-startup>
</servlet>
I've tried using priorty 1 also,
My servlet log just says
2001-07-10 02:50:05 - path="/examples" :jsp: init
2001-07-10 02:50:05 - path="/datacenter" :jsp: init
2001-07-10 02:50:05 - path="/admin" :jsp: init
And when i start tomcat the error i get is :
cannot load servlet name: TrapReceiver.class
The TrapReciever.class file is located in C:\tomcat\webapps\examples\WEB-INF\classes
I've tried <servlet-class>
TrapReceiver.class
& also/webapps/examples/WEB-INF/classes/TrapReceiver.class
</servlet-class>
But to no avail
Can anyone shed any light on this ??

Hi Michael,
Where did u put u r web.xml file?. If its not in the /example/web-inf/web.xml then paste u r <servlet> tag there. And it should work.
I think tomcat is more comfortable if u use the packages for all the classes u use.
Hope this will help u
Cherry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic