• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Example for load a servlet repeatedly

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was reading this section on 'Servlet Reloading' of Jason Hunters Java Servlet Programming.
Then I went in search of an example.
I read in Core Java II Advanced Features Vol II 7th ed.

On P696 it mentions using classloaders to facilitate such things as hot deployment of servlets and EJBs.
It makes references to this broken link:
http://developer.java.sun.com/developer/TechTips/2000/tt1027.htm
I'm wondering if anyone knows what's become of this document?
(I couldn't see it on the Waybackmachine either.
Does anyone have a link that:
1) Shows a custom class loader to load servlets repeatedly?
2) A new link for the broken one?
Cheers.
 
Greenhorn
Posts: 25
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Jeremy Flowers
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
karan khosla
Greenhorn
Posts: 25
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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). :-)
 
karan khosla
Greenhorn
Posts: 25
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you've got any links that you think would be worth sharing, that would be cool too. Thanks.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 28344
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Paul Clapham
Sheriff
Posts: 28344
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
karan khosla
Greenhorn
Posts: 25
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Paul/Ulf

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.

Regards,
Karan
 
Sheriff
Posts: 67752
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
HItting the servlet with a request does not "reload" the servlet. You are confusing reloading with returning a response,
 
Jeremy Flowers
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:HItting the servlet with a request does not "reload" the servlet. You are confusing reloading with returning a response,


Was that meant for Karan? :-)
 
Bear Bibeault
Sheriff
Posts: 67752
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
Yes.
 
karan khosla
Greenhorn
Posts: 25
IntelliJ IDE Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear,

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.

Regards,
Karan
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
karan khosla
Greenhorn
Posts: 25
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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. :-)

Regards,
Karan
 
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic