• 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

how to deploy servlet at startup

 
Ranch Hand
Posts: 235
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I have a servlet DaemonHttpServlet and want to load it during startup tomcat. I am using Socket connect applet and servlet.
I know I should modify web.xml file like
<servlet>
<servlet-name>???</servlet-name> <servlet-class>DaemonHttpServlet</servlet-class><load-on-startup/>
</servlet>
is that correct? but i dont have a servlet name for it?
and also is this web.xml file in Root directory?
When I start tomcat, it gives me "can not load servlet name: DaemonHttpServlet.
Please clarify my confusion,
Thank you very much,
Simon
 
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 need to assign a servlet name - why do you say you don't have one? Just use DaemonHttpServlet as the name if you don't have any other preference.
The servlet-class element must contain the fully qualified class name. If the class has no package, it is already correct as is.
The class and the web.xml file can be placed in any web application. For example, if you have Tomcat installed at $TOMCAT_HOME, then the files should be
$TOMCAT_HOME/webapps/test/WEB-INF/web.xml
$TOMCAT_HOME/webapps/test/WEB-INF/classes/DaemonHttpServlet.class
where "test" can be any web application under $TOMCAT_HOME/webapps (such as "examples", if you don't want to create a new one).
------------------
Phil Hanna
Author of :
JSP: The Complete Reference
Instant Java Servlets
 
Simon Xu
Ranch Hand
Posts: 235
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, Phil,
Thanks for your prompt reply.
Can I load an abstract servlet (class)? Thanks,
Simon
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simon,
A sample web.xml which I tested to auto-load is :

We can't auto-load abstract servlet classes since the servlet engine can'e instantiate the servlet and load an 'abstract class' into memory.
regds
maha anna
 
Simon Xu
Ranch Hand
Posts: 235
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, Maha,
Thanks for your expl.
Simon
 
Check your pockets for water buffalo. You might need to use this tiny ad until locate a water buffalo:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic