views:

42

answers:

2

I have a web page where I redirect the user to if I see that IP is not valid. I want that user's browser will get no response but kept into waiting state, but I also want that my server thread is not blocked for that request. So the idea was that server will response quickly but the user' browser will put into waiting loop to discourage the user. How can I achieve this easily? Is it possible without JavaScript? If JavaScript is the only way then suggest that solution.

Thanks

+1  A: 

The problem here is that HTTP is a request/response protocol. If you are redirecting the user, you're responding to that original request. Unless the user generates another request (via javascript or whatever) then the server can't respond again.

You don't need to put the browser into a 'waiting state', if the server simply doesn't reply to the request the browser will just keep on waiting.

I think you're trying to say that your IP task takes a long time, and how to deal with that effectively?

Perhaps if you clear up your question I can answer more fully.

m.edmondson
I send a request to the server. Server responds back quickly. But I want that browser should keep showing that animation/progress bar that page is loading but never get it. How to achieve that?
kumar
Upon creating the request some client-side loading animation becomes visible, when the server is ready to respond it will, and the user sees the result. Simple.
m.edmondson
A: 

No this is not possible. The problem is to keep the browser waiting with no response you need to keep the connection open and not write to it. The result of this will be:

  • It will cause your server to run out of connections and use memory to maintain connections
  • The client will timeout, even if you do not reply

You could purhaps reply with a page that contained a java script with an infinate loop.

Shiraz Bhaiji
I disagree that you should ever delay a response, why would you ever make a user wait on purpose?
m.edmondson
That is why I asked that I don't want to keep the request held on server as it can consume all available connections if more similar requests come. If JS is the only way then I think that is also not bad.
kumar
This really isn't a good way forward
m.edmondson
@eddy556, I agree that this is not a good way forward, my answer was why this is a bad idea
Shiraz Bhaiji
Please do no vote for bad or good idea. I need an answer how to do this. Is it possible without JavaScript? If not then I can handle it with JavaScript.
kumar