how to call a javascript file from a servlet?

Discussion in 'Java' started by Ryan Gaffuri, Sep 30, 2004.

  1. Ryan Gaffuri

    Ryan Gaffuri Guest

    I would prefer not to include my javascript in my servlet. its too
    messy. I am using j avascript to check for form errors(such as nulls
    in fields). anyway to put my javascript in a seperate script and call
    it from my servlet?
     
    Ryan Gaffuri, Sep 30, 2004
    #1
    1. Advertising

  2. Ryan Gaffuri

    Bryce Guest

    On 30 Sep 2004 07:38:12 -0700, (Ryan Gaffuri) wrote:

    >I would prefer not to include my javascript in my servlet. its too
    >messy. I am using j avascript to check for form errors(such as nulls
    >in fields). anyway to put my javascript in a seperate script and call
    >it from my servlet?


    What do you mean including javascript in your servlet? The javascript
    code in the response?

    If so, I use JSP's, and just include the file there...

    --
    now with more cowbell
     
    Bryce, Sep 30, 2004
    #2
    1. Advertising

  3. Ryan Gaffuri wrote:
    > I would prefer not to include my javascript in my servlet. its too
    > messy. I am using j avascript to check for form errors(such as nulls
    > in fields). anyway to put my javascript in a seperate script and call
    > it from my servlet?


    The output of a Servlet is a simple HTML page, so once it's delivered to
    the client it has all the limitations and capabilities of one, including
    the ability to refer the separate JavaScript files with the src attribute
    of the script tag.
     
    Michael Borgwardt, Sep 30, 2004
    #3
  4. Ryan Gaffuri

    Tim Slattery Guest

    (Ryan Gaffuri) wrote:

    >I would prefer not to include my javascript in my servlet. its too
    >messy. I am using javascript to check for form errors(such as nulls
    >in fields). anyway to put my javascript in a seperate script and call
    >it from my servlet?


    Servlets run on the server. JavaScript runs on the client. You cannot
    call a function on the client from the server.

    --
    Tim Slattery
     
    Tim Slattery, Sep 30, 2004
    #4
  5. Ryan Gaffuri

    Carl Howells Guest

    Ryan Gaffuri wrote:
    > I would prefer not to include my javascript in my servlet. its too
    > messy. I am using j avascript to check for form errors(such as nulls
    > in fields). anyway to put my javascript in a seperate script and call
    > it from my servlet?


    Please tell me you're not using *only* javascript to test for form
    errors... Please tell me everything is being double-checked sever-side,
    too.

    Never rely on client-side validation of data.
     
    Carl Howells, Sep 30, 2004
    #5
  6. Ryan Gaffuri

    Will Hartung Guest

    "Ryan Gaffuri" <> wrote in message
    news:...
    > I would prefer not to include my javascript in my servlet. its too
    > messy. I am using j avascript to check for form errors(such as nulls
    > in fields). anyway to put my javascript in a seperate script and call
    > it from my servlet?


    And rather than questioning the overall design, the answer to your question
    is, Yes, you can call JavaScript from your Servlet.

    Netscape/Mozilla has the Rhino JavaScript interpreter written in Java which
    is actually quite nice. You can embed the interpreter into your servlets and
    it will run JavaScript for you.

    It will NOT, however, have access to the actual HTML form page (as that's in
    the browser), but it will run JavaScript from a Servlet.

    Regards,

    Will Hartung
    ()
     
    Will Hartung, Sep 30, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Fish
    Replies:
    4
    Views:
    2,451
    Andy Fish
    Dec 17, 2003
  2. Sean Clarke
    Replies:
    1
    Views:
    1,948
    Sudsy
    Jan 7, 2004
  3. circuit_breaker
    Replies:
    2
    Views:
    2,085
    Jack Jia
    Apr 4, 2004
  4. chamikara
    Replies:
    1
    Views:
    49,971
  5. DiscoStu
    Replies:
    0
    Views:
    531
    DiscoStu
    Jul 8, 2004
Loading...

Share This Page