Executing server code

T

titogarcia

I want to execute server code invoked from inside Javascript code.

I will have my server code in a servlet, callable with a URL, but how
do I invoke the servlet from Javascript without reloading the page and
not opening any window? I mean, I don't want to display the HTML result
of this request.

Regards,
Ernesto
 
V

VK

invoke the servlet from Javascript without reloading the page and
not opening any window?
I mean, I don't want to display the HTML result
of this request.

You don't need any JavaScript then: simply return

HTTP/1.0 204 No content

response from you servlet and user will stay on the current page.
 
H

Hywel Jenkins

I want to execute server code invoked from inside Javascript code.

I will have my server code in a servlet, callable with a URL, but how
do I invoke the servlet from Javascript without reloading the page and
not opening any window? I mean, I don't want to display the HTML result
of this request.

Ajax.
 
D

David Wahler

VK said:
You don't need any JavaScript then: simply return

HTTP/1.0 204 No content

response from you servlet and user will stay on the current page.

That's really interesting; I'd never heard of that response code
before. I guess these days (with XMLHttpRequest being so popular) it's
not such a big deal, but it's still nice to know about. Thanks!

By the way, I know this is in the HTTP standard but are there any major
browsers that don't support it? I've just tested with Firefox 1.0.6 and
IE 6.0 and it works fine.

-- David
 
V

VK

David said:
That's really interesting; I'd never heard of that response code
before. I guess these days (with XMLHttpRequest being so popular) it's
not such a big deal, but it's still nice to know about. Thanks!

By the way, I know this is in the HTTP standard but are there any major
browsers that don't support it? I've just tested with Firefox 1.0.6 and
IE 6.0 and it works fine.

HTTP/ ***1.0*** 204 No content

This header is fully supported starting NCSA Mosaic and even earlier in
Gopher prototypes.
The only ever existed issue was with IE >= 5.1 && IE < 5.5 - on this
platform one got hourglass coursor for the system timeout period
(despite the page still did not change).

I wrote an article here about this header but cannot google it out -
that was some week, my head doesn't work. Anyway - the history of this
header really needs to be described some day as a shining sample: how
people do not see sometimes things which they need desperately - if
such things are too close to their nose.

This header existed *for years* before in late 90's one currently
disappeared US-based online music CD store started to use it in their
shoppping basket program. Competitors spyed for the trick, stole HTML
codes(for no avail naturally) - and no one guessed to simply open damn
public HTTP specs. :)

Any way - use it with no fear... and roalty-free :)
 
R

Randy Webb

Hywel Jenkins said the following on 11/18/2005 12:47 PM:

Why not something that is 100% compatible with any scriptable browser?

document.images['someImage'].src="serverSideScriptToExecute.PHP";

Now, no need to depend on ActiveX or native HTTPRequest support, only
images collection and scripting.
 
V

VK

David said:
That's really interesting; I'd never heard of that response code
before. I guess these days (with XMLHttpRequest being so popular) it's
not such a big deal, but it's still nice to know about. Thanks!

By the way, I know this is in the HTTP standard but are there any major
browsers that don't support it? I've just tested with Firefox 1.0.6 and
IE 6.0 and it works fine.

HTTP/ ***1.0*** 204 No content

This header is fully supported starting NCSA Mosaic and even earlier in
Gopher prototypes.
The only ever existed issue was with IE >= 5.1 && IE < 5.5 - on this
platform one got hourglass coursor for the system timeout period
(despite the page still did not change).

I wrote an article here about this header but cannot google it out -
that was some week, my head doesn't work. Anyway - the history of this
header really needs to be described some day as a shining sample: how
people do not see sometimes things which they need desperately - if
such things are too close to their nose.

This header existed *for years* before in late 90's one currently
disappeared US-based online music CD store started to use it in their
shoppping basket program. Competitors spyed for the trick, stole HTML
codes(for no avail naturally) - and no one guessed to simply open damn
public HTTP specs. :)

Any way - use it with no fear... and roalty-free :)
 
E

Ernesto García García

Thanks to all who answered.

For now I think I will use XMLHttpRequest as I have todo it within
Javascript and I am sure of the browser version that the clients will be
using.

Regards,
Ernesto
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top