Executing server code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • titogarcia@gmail.com

    #1

    Executing server code

    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

    #2
    Re: Executing server code


    titogarcia@gmai l.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.

    Comment

    • Hywel Jenkins

      #3
      Re: Executing server code

      In article <1132334912.273 288.263960@g43g 2000cwa.googleg roups.com>,
      titogarcia@gmai l.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

      Comment

      • David  Wahler

        #4
        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

        Comment

        • VK

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

          Comment

          • Randy Webb

            #6
            Re: Executing server code

            Hywel Jenkins said the following on 11/18/2005 12:47 PM:
            [color=blue]
            > In article <1132334912.273 288.263960@g43g 2000cwa.googleg roups.com>,
            > titogarcia@gmai l.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="serverSid eScriptToExecut e.PHP";

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

            --
            Randy
            comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
            Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

            Comment

            • VK

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

              Comment

              • Jasen Betts

                #8
                Re: Executing server code

                On 2005-11-18, titogarcia@gmai l.com <titogarcia@gma il.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

                Comment

                • Ernesto García García

                  #9
                  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

                  Comment

                  Working...