Connecting Tech Pros Worldwide Forums | Help | Site Map

Executing server code

titogarcia@gmail.com
Guest
 
Posts: n/a
#1: Nov 23 '05
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


VK
Guest
 
Posts: n/a
#2: Nov 23 '05

re: Executing server code



titogarcia@gmail.com wrote:[color=blue]
> invoke the servlet from Javascript without reloading the page and
> not opening any window?[/color]
[color=blue]
>I mean, I don't want to display the HTML result
> of this request.[/color]

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.

Hywel Jenkins
Guest
 
Posts: n/a
#3: Nov 23 '05

re: Executing server code


In article <1132334912.273288.263960@g43g2000cwa.googlegroups .com>,
titogarcia@gmail.com says...[color=blue]
> 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.[/color]

Ajax.

--

Hywel
http://kibo.org.uk/
David Wahler
Guest
 
Posts: n/a
#4: Nov 23 '05

re: Executing server code


VK wrote:[color=blue]
> 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.[/color]

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

VK
Guest
 
Posts: n/a
#5: Nov 23 '05

re: Executing server code



David Wahler wrote:[color=blue]
> 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.[/color]

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 :-)

Randy Webb
Guest
 
Posts: n/a
#6: Nov 23 '05

re: Executing server code


Hywel Jenkins said the following on 11/18/2005 12:47 PM:
[color=blue]
> In article <1132334912.273288.263960@g43g2000cwa.googlegroups .com>,
> titogarcia@gmail.com says...
>[color=green]
>>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.[/color]
>
>
> Ajax.
>[/color]

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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
VK
Guest
 
Posts: n/a
#7: Nov 23 '05

re: Executing server code



David Wahler wrote:[color=blue]
> 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.[/color]

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 :-)

Jasen Betts
Guest
 
Posts: n/a
#8: Nov 23 '05

re: Executing server code


On 2005-11-18, titogarcia@gmail.com <titogarcia@gmail.com> wrote:[color=blue]
> 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.[/color]

It's called "ajax". and done via the xmlHttpRequest (etc) function.


Bye.
Jasen
Ernesto García García
Guest
 
Posts: n/a
#9: Nov 23 '05

re: Executing server code


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
Closed Thread