Results 1 to 3 of 3
  1. #1
    sandor is offline Member
    Join Date
    Apr 2007
    Location
    Pennsylvania,USA
    Posts
    45
    Rep Power
    0

    Default 1 form 2 servlets

    I have one HTML form, can I have two submit buttons that send the values in the form to two separate servlets?
    tia

  2. #2
    derrickD is offline Member
    Join Date
    Apr 2007
    Location
    USA
    Posts
    50
    Rep Power
    0

    Default

    Yes, this can be done but don't use a submit. Just use a regular button and write a JavaScript function that gets called onclick() that sends the request to the appropriate URL mapped to the appropriate servlet.
    Another option would be to send the request to the same servlet, but let the servlet delegate to an appropriate action based on the value of the submit request parameter. But, I hate to use an if statement and conditional logic if not needed.

  3. #3
    loveshore is offline Member
    Join Date
    Jan 2008
    Posts
    2
    Rep Power
    0

    Default

    Sandor,
    As 'derricD' mentioned, submit is not a good option here. You can have two separate command buttons instead of submit. On button click you can call a javascript method, specify the servlet path as follows

    document.all.form.attributes["action"].value = "\your servlet path here";

Similar Threads

  1. Java Servlets
    By kondalrao in forum Java Servlet
    Replies: 0
    Last Post: 04-14-2008, 12:12 PM
  2. Deploying Servlets
    By gapper in forum New To Java
    Replies: 2
    Last Post: 01-17-2008, 01:43 PM
  3. servlets or jsp
    By krishnapal in forum Advanced Java
    Replies: 1
    Last Post: 12-13-2007, 03:31 PM
  4. Servlets
    By nagaroopanandha in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 03:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •