This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

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

 
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
 
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 ]
 
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 ]
 
Sheriff
Posts: 67261
170
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
Sheriff
Posts: 67261
170
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
 
Live ordinary life in an extraordinary way. Details embedded in this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!