Requesting data from multiple forms which have the same action

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RAKESH BALAIAH
    New Member
    • Dec 2010
    • 6

    Requesting data from multiple forms which have the same action

    Hi,
    I'm using an HTML page in which i've 2 forms which have the same action..
    Ex:

    <form name="f1" action="store.j sp" method="post">
    <!-- Do something -->
    </form>
    <form name="f2" action="store.j sp" method="post">
    <!-- Do something -->
    </form>

    Now in the JSP page how can i retreive the parameters of form f2 using request.getPara meter('Paramete r name');
    Is there any method like request.getPara meter(form name,parameter name);
    (or)
    form_name.reque st.getParameter (Parameter_name );

    Help me out please..
  • AutumnsDecay
    New Member
    • Mar 2008
    • 170

    #2
    Why not append action to your url?

    Example:

    Code:
    <form action="store.jsp?action=form1" method="get">
        ...more code...
    </form>
    
    <form action="store.jsp?action=form2" method="get">
        ...more code...
    </form>
    Then on your jsp page you can have it process differently based on the action that was set in the url, similar to PHPs ability which is:

    Code:
    if ($_GET['action'] == "form1"){
       process this code...
    }
    
    if ($_GET['action'] == "form2"){
        process this code instead...
    }

    Comment

    • RAKESH BALAIAH
      New Member
      • Dec 2010
      • 6

      #3
      well thank u very much for your valuable suggestion. but can i use both actions for processing a single set of statements
      regards,
      rakhi

      Comment

      Working...