Are you using ajax or jquery in your application or rather the page for which you want to reload the servlet everytime. If yes than it's quite possible to achieve without this classloading stuff.
karan khosla wrote:Are you using ajax or jquery in your application or rather the page for which you want to reload the servlet everytime. If yes than it's quite possible to achieve without this classloading stuff.
Hope this Helps!
Regards,
Karan
Hi Karan.
No this was something I saw in a Java interview question and was curious to know how to do this. It's something I've never come across before.
Well Sir you have to first clear me that are you using ajax or jquery in your application? If not than i guess it's a bit long path.
Either ways it will take some time for me to actually code an example for you.
Regards,
Karan
Jeremy Flowers
Greenhorn
Joined: Aug 04, 2005
Posts: 11
posted
0
karan khosla wrote:Well Sir you have to first clear me that are you using ajax or jquery in your application? If not than i guess it's a bit long path.
No Ajax/JQuery. Plain old Java only (Servlets forum). :-)
No Problems. I will show you both ways but as i said i need some time to code a sample application when i am done with that i will post here. It's actually a good question i will be posting the same on my blog [http://pythonicway.blogspot.com/] only after it works for you.
Regards,
Karan
Jeremy Flowers
Greenhorn
Joined: Aug 04, 2005
Posts: 11
posted
0
If you've got any links that you think would be worth sharing, that would be cool too. Thanks.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35248
7
posted
0
What Jeremy is asking about has nothing to do with AJAX and/or jQuery. The "reloading" in question is not the repeated accessing of a web page by a client, but the reloading of a servlet class after its code has changed.
Those early Java Tech Tips have gone missing a while ago, and are unlikely to resurface; you can find an archived copy here. More recent ones from 2007 onwards can be found at http://java.sun.com/developer/TechTips/index.html.
I have no idea why client-side technologies like AJAX would have anything at all to do with hot deployment of servlets, which is entirely a server-side requirement. But perhaps Karan will enlighten us eventually.
In the meantime, I have to ask why you are so interested in this? That book was written back in the dark ages -- the page you linked to is dated March 2001, ten years ago -- which is why you can't find the other pages you were looking for. A lot of servlet containers these days have addressed that problem since that time and support hot-deployment via a configuration option. Or were you considering writing your own servlet container?
Jeremy Flowers
Greenhorn
Joined: Aug 04, 2005
Posts: 11
posted
0
Paul Clapham wrote:I have no idea why client-side technologies like AJAX would have anything at all to do with hot deployment of servlets, which is entirely a server-side requirement. But perhaps Karan will enlighten us eventually.
In the meantime, I have to ask why you are so interested in this? That book was written back in the dark ages -- the page you linked to is dated March 2001, ten years ago -- which is why you can't find the other pages you were looking for. A lot of servlet containers these days have addressed that problem since that time and support hot-deployment via a configuration option. Or were you considering writing your own servlet container?
I figured the outdated article if it was still around somewhere would give me enough information to understand how you'd implement loading a servlet repeatedly using a classloader, which I guess is the real "nut I'm trying to crack"!
Cheers.
Jeremy Flowers wrote:I figured the outdated article if it was still around somewhere would give me enough information to understand how you'd implement loading a servlet repeatedly using a classloader, which I guess is the real "nut I'm trying to crack"!
Okay... but I'm still curious about why you are trying to crack that nut in the first place.
Jeremy Flowers
Greenhorn
Joined: Aug 04, 2005
Posts: 11
posted
0
Paul Clapham wrote:
Jeremy Flowers wrote:I figured the outdated article if it was still around somewhere would give me enough information to understand how you'd implement loading a servlet repeatedly using a classloader, which I guess is the real "nut I'm trying to crack"!
Okay... but I'm still curious about why you are trying to crack that nut in the first place.
Curiousity. :-) Classloaders in general are a weak spot for me. A use case giving a reason why you'd loading a servlet repeatedly with a classloader would also help.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35248
7
posted
1
Jeremy Flowers wrote:Classloaders in general are a weak spot for me.
If I may strut my own stuff: Here's an article I wrote a while back that demonstrates a custom classloader in action. It's a desktop app, not a web app, but the source is included so it's easy to experiment with it.
A use case giving a reason why you'd loading a servlet repeatedly with a classloader would also help.
It used to be that starting and stopping a web app was a rather slow process (we're talking 10 years ago here), so to make the development process faster servlet containers would check the date/time on servlet class files, and automatically reload them if the date was newer than the last known date. These days, containers can be set to reload the entire web app which -given the speed of current machines- is generally a pretty fast process, so the possibility of reloading single servlets has gone away.
Well via ajax or jquery and reloading a servlet is a easy bet in the sense that you can pass any random value to a servlet as request parameter which will force the container to relead the servlet for you for now i can tell only this thing. And yes maybe you both are correct that what Jeremy was asking is something different than what i thought than, i would say the classloader stuff is another way to go.
Sir, You're Correct that hitting a servlet with request won't reload a servlet but if the servlet takes request parameter and you change that parameter on every call via a ajax or jquery it will force the underlying container to reload the servlet for sure. Still i would say correct me if i am wrong. I did this thing in one of my projects and it worked for me at that time.
This is still incorrect. A servlet gets loaded by the container and uses that single instance to serve all requests of that type. The container can decide to undeploy a servlet and then redeploy a servlet, but in practice this is unlikely to point that I've never seen single case of this in over 12 years.
Sending different request parameters will not cause the servlet to undeploy, it will not cause a new instance to be created.
If you can show otherwise then please post the code and steps to reproduce it here.
If the browser sends a request to the servlet then the browser may show new information on the client side, but this has no relation to the single servlet instance which exists on the server.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35248
7
posted
0
karan khosla wrote:Still i would say correct me if i am wrong.
You're wrong :-)
"reloading a servlet" has nothing at all to do with "reloading a page served by a servlet". Jeremy asked about the former, while Karan is talking about the latter.
If you guys think i am wrong than i accept that :-) Still in a learning stage. Maybe i am not able to completely understand the scenario or what i did is something different. :-)