File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP's not capable of promting the client for request?

 
Nikhil Menon
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nikhil Menon
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic