• 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 get servlets to reload automatically when server is reset?...

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone know how I can achieve this?

Thanks in advance,
James
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
James,
Can you explain what you mean?

The servlet classes do get reloaded if you restart the server.
[ February 21, 2005: Message edited by: Ben Souther ]
 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know exactly what he's talking about. He wants his servlets to automagically reload when he changes them and he doesn't want to restart the server because that is not intuitive and not something that seems logical. I got tripped up on this when I started and I just couldn't figure out why Tomcat wouldn't reload my web app by default.

Would I restart apache everytime I change a php script? I think not.

The way you have to do this is to set up a context for your web application then set it's reloadable property to true. I won't tell you exactly how to do this because I am also starting out and I don't want to tell you the wrong way to go about it and there are many tutorials on google.com which describe how to do this.

I also beleive that <DefaultContext reloadable="True"> inside conf/web.xml will also do it but don't quote me on it.

Check this out:

http://www.jspbook.com/freechapters.jsp

There is an entire free JSP/Servlet book for download. I have been reading through this and it's given me the exact information I needed to understand what the hell this server side java stuff is all about. I suggest you also read this. It's worth the price of free!!!
[ February 21, 2005: Message edited by: Frank Hale ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

He wants his servlets to automagically reload



If that's what he meant, his question could use some rewording.

Would I restart apache everytime I change a php script? I think not.



Not a particularly apt analogy. php scripts are more akin to JSP pages which do automatically reload.

That said, yes, setting up the context to reload automatically in the debug environment (this is not appropriate for a production system) is a good way to go. Note, only the app context requires reloading: stoppng and starting the entire server is not necessary.

This can also be done "by hand" using the manager application.
[ February 21, 2005: Message edited by: Bear Bibeault ]
 
Frank Hale
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I must admit after rereading his post he was trying to do something else. I misread. Sorry!
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No need for an apology. You're trying to help. That's good!
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replies guys. I was looking for the init() method to be called at server startup - sorry for not making that clear.

I've found the solution now - the <load-on-startup> tag.

Cheers,
James
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic