• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get servlets to reload automatically when server is reset?...

 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know how I can achieve this?

Thanks in advance,
James
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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 ]
 
Frank Hale
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • 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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
I must admit after rereading his post he was trying to do something else. I misread. Sorry!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic