| Author |
JSP's not capable of promting the client for request?
|
Nikhil Menon
Ranch Hand
Joined: Nov 22, 2004
Posts: 70
|
|
Hi all, I had a theoritical question. Why a JSP is not capable of prompting the client(Browser) for input rather than just waiting for one from the client. Why is this functionality not given for a JSP? JSP's cant send anything to client with being requested. Why so? Can anyone throw some light on it, please. Thank you. Nikhil
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Because HTTP is a stateless protocol. JSPs live on a server. They wait on the server for a request. When they get a request, they return a response. The connection is then dropped and the JSP sits and waits for another request. This is how the web works, it's no different with .NET, PHP, ASP, CF, etc.. [ February 15, 2005: Message edited by: Ben Souther ]
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Nathan Pruett
Bartender
Joined: Oct 18, 2000
Posts: 4121
|
|
Because JSP's dynamically generate HTML pages. HTML pages are sent using HTTP. HTTP is based around a request/response cycle. Making JSPs able to request values from a client instead of waiting for the client to respond would require a different protocol, or require a pretty massive workaround, such as refreshing the page every x seconds so HTTP responses are generated very often, allowing the server to get data when it is ready to "request" it. However, this would be very bad as far as bandwith and scalability are concerned... instead of sending a page only when the user requests it, your server would *constantly* be sending pages... most of which would be the exact same as the version that had just been sent. You could use some of the HTTP response headers to make this not as bad of a hit, though, like have your controller servlet mess around with the "last-modified" Header and send body-less responses unless it needs to pull values. But this still requires a lot of requests, a complex framework, and a complex client-side setup (that can easily be broken just by the client shutting off JavaScript), so it's probably just not worth it.
|
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
|
 |
Nikhil Menon
Ranch Hand
Joined: Nov 22, 2004
Posts: 70
|
|
Aahhh http is a stateless protocol. I forgot that point. Ben thaks for your help. You gave the right answer. Thank you
|
 |
Nikhil Menon
Ranch Hand
Joined: Nov 22, 2004
Posts: 70
|
|
this would be very bad as far as bandwith and scalability are concerned... by Nathan Pruett
I agree to you Nathan,Ben it would be a failure if tried to implement it this way. Thank you Nathan for your explanation...
|
 |
 |
|
|
subject: JSP's not capable of promting the client for request?
|
|
|