How to submit two forms once  in one jsp page?

hello all,
My jsp page includes two forms: one form's action is a File Upload servlet, which process file uploading; another is a general servlet to collect user inputs, such as user name, age, etc.
Because the file upload servlet is a legacy component, and it was used in many applications. we could not meger it into our business components.
the system requires the file upload and information collection are submitted once. so we have to submit two forms in one 'Submit' action, at the same time, the information collection servlet need get the information from file upload servlet, such as the uploaded file's url.
I have tried two methods, but all failed
1. Upload form has no a 'Submit' button, when user click the 'submit' button of the information collection form, we use a javascript to submit upload form first, then submit information collection form. Failed at: the second submit dose wait for upload finishing, then the second submit interrupt the upload
2. the javascript only submit upload form, and set HTML body's onUnload event to another javascript that submit information collection form. this time, the file upload sucess, and information collection form sucess at most time. But fail when user click the 'refresh' or 'back' or any navigator buttons of the browser. these action will trigger the page 'unload' event too, but the submit if invalid!
Please tell me how to.

chain the both requests!
- build one mutlitpart request and send it to a servlet that can handle that multipart request (think of using oreilly MultiPartParser).
- check the input (all requiered fields and files there)
- if yes store the user fields and create a socket connection from your servlet to the legacy file upload servlet and post the file this way.
- like this you have full control over the users input and can make sure the file and the fields are just save if all requiered elements are availble.

Similar Messages

  • How to submit a form with checkboxes in a page flow?

    I'm having some trouble with a form that contains several checkboxes, and
    how to submit this form within a page flow...
    I have a JSP page containing a form with N checkboxes. The value and
    checked/unchecked status of each checkbox is generated from parsing an XML
    document. Here is the (simplified) code:
    <%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
    <netui:form action="doUpdate">
    <x:forEach select="...">
    <input type="checkbox" name="id"
    <x:if ...>checked</x:if> value="<x:out ... />">
    </x:forEach>
    <netui:anchor formSubmit="true" action="doUpdate">Submit</netui:anchor>
    <netui:anchor action="doCancel">Cancel</netui:anchor>
    </netui:form>
    When this form is submitted, the checkbox values are lost -- the following
    code (in the action) produces an empty array:
    String[] prefs = this.getRequest().getParameterValues("id");
    I looked at the <netui:checkbox> tag, but it does not appear to give me a
    way to set the state and value (unless I've missed something).
    Can I submit a form without using a form bean? If I do use a form bean, can
    I set the state and value from my JSP?
    Any suggestions on how to do this (or insights into what I'm doing wrong)
    are welcome...
    -- Craig

    I am new to this, but I think this may solve your problem:
    I am not sure if this is what you are looking for, but you can create a LinkedHashMap
    with the req key/value pairs in the page-calling action in the pageflow and then
    pass that via a getRequest().setAttribute("myCheckboxes",myCheckboxHashMap);
    You can then access it in code using the optionsDataSource portion of the netui:checkBoxGroup
    - ie
    <netui:checkBoxGroup dataSource="{actionForm.thisCheckbox}" optionsDataSource="{request.myCheckboxes}">
    Hope this helps!
    m
    "Craig Coffin" <craig+1268fbec@nfld-dot-com> wrote:
    I'm having some trouble with a form that contains several checkboxes,
    and
    how to submit this form within a page flow...
    I have a JSP page containing a form with N checkboxes. The value and
    checked/unchecked status of each checkbox is generated from parsing an
    XML
    document. Here is the (simplified) code:
    <%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
    <netui:form action="doUpdate">
    <x:forEach select="...">
    <input type="checkbox" name="id"
    <x:if ...>checked</x:if> value="<x:out ... />">
    </x:forEach>
    <netui:anchor formSubmit="true" action="doUpdate">Submit</netui:anchor>
    <netui:anchor action="doCancel">Cancel</netui:anchor>
    </netui:form>
    When this form is submitted, the checkbox values are lost -- the following
    code (in the action) produces an empty array:
    String[] prefs = this.getRequest().getParameterValues("id");
    I looked at the <netui:checkbox> tag, but it does not appear to give
    me a
    way to set the state and value (unless I've missed something).
    Can I submit a form without using a form bean? If I do use a form bean,
    can
    I set the state and value from my JSP?
    Any suggestions on how to do this (or insights into what I'm doing wrong)
    are welcome...
    -- Craig

  • How to display result in more than one jsp page

    Hi all,
    the result is a very large it will take more than one jsp page in this senario how we will display the result in more than one jsp page.
    Thanks in Advance.

    The magic word is "paging". Look around using this keyword.
    Basically it's all about subquerying, (eventually) caching and sublisting.

  • How to submit two forms at same time?

    Have a client that requires their members to update their profile information and some of the details from that form need to also populate a WebApp.
    I've seeded the CRM with basic (first name, last name, email address, Your ID, and EntityID) member data.
    Members would log in and be asked to update their profile. [action="/MemberProcess.aspx"]
    This submission should update their CRM record *AND* create a WepApp record at the same time.
    I tried the AJAX + jQuery method, including the second WebApp form [action="/CustomContentProcess.aspx?...] fields as type="hidden", and using {tag_FIELD NAME}; but this isn't working for me, I'm admittedly not a real programmer.
    Any thoughts? Thank you very much, in advance for any and all help!
    p.s. the reason for wanting to do this, is so that members do not have to update their CRM profile and then also input their data specific to the WebApp form (it's a member listing) as a separate task.
    p.p.s. after I get through the above hurdle... how can I ensure that a CRM user has one and only one WebApp item (their listing) and that they can edit it? Another issue I'm having now is that users create a new listing in the WebApp if they submit another record and in the future I fear that simply editing their CRM profile will create new WebApp listings too. This site is like a phone book, there should only be one listing for each unique email address (in this case).
    -Will

    You can use Jquery + AJAX to submit as many forms as you want to as many places as you want. Don't use the HTML to submit and have a second javascript submitter as the Javascript might not have time to complete before the page is submitted.
    I wrote this quickly just now, this wont work on the JSfiddle site because you can't form POST / GET anything on it (AJAX included it seems). it will submit to other URLs the same data. It is done in parallel and because we don't know which one will finish quicker, both calls check if all calls are complete before confirming everything is complete. I have not tested it but it would get you 99% of the way there.
    <form id="signup_register" action="" method="post">
        Firstname<br/><input type="text" name="firstname"><br/>
        Lastname<br/><input type="text" name="lastname"><br/>
        <button onclick="formsubmit(this);">Save</button>
    </form>
    <script>
        var url1='http://google.com';
        var url2='http://gmail.com';
        var complete1=false;
        var complete2=false;
        FinishedTwoFormSubmits=function(){
            alert('Finished submit - redirect or whatever you need to do.');   
        formsubmit=function(el){
            var data = $('form#signup_register').serializeArray();
            PostSubmit(url1,data, function(){ complete1=true; if (complete1 && complete2){ FinishedTwoFormSubmits() } });
            PostSubmit(url2,data, function(){ complete2=true; if (complete1 && complete2){ FinishedTwoFormSubmits() } });
        PostSubmit=function(url,data,cb){
              var ret=false;
            var noerror=false;
                        $.ajax({
                                    type: 'POST',
                                    url: url,
                                    cache: false,
                                    data: data
                                  }).done(function(msg) {
                                            try{ noerror=true; }
                                            catch(e){ alert(e+'\n\n'+msg); }
                                            if (noerror){ cb() }
                        return ret;
    </script>

  • How to print two delivery challans in one single page

    Hi Experts,
    Here we have a requirement that,
    The user wants the two Delivery challan outputs in one page.
    and also for some documents he requires header and for some documents he doesn't require,
    for this what condition should require.
    Any idea regarding this...
    Thanks in adv
    Thushara

    do 2 times
    perform write_form.
    end do.
    for header u can give condtion in form.
    use if condition in the editor...
    this will help u...
    Reward IF....... <= IF what? Points removed... read [the rules|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement]!
    Regards
    Anbu
    Edited by: Julius Bussche on Jul 17, 2008 7:01 PM

  • How to call the form bean value on jsp withthe help of jstl tag

    hi
    all friends
    i am working in struts & i use jstl tag in jsp. i have one problem rise is how to call the form bean value in jsp page by using jstl tag.
    i now how to retrive the value through jsp:logic
    eg. <logic:empty name="userListForm" property="users">
    NO USER FOUND
    </logic:empty>
    see * userListForm mean formbaen name.
    * users means collection object.
    so how can i write above e.g in jstl

    You use the jstl core:if or core:choose combined with the EL:
    <c:if test="${empty users.userListForm}">
    NO USERS FOUND
    </c:if>I suggest you lookup the jsp expression language (EL) using google, it's very powerful.

  • Forms integration into a JSP page

    There is a great White Paper on the OTN's home page about how to integrate a Forms application within a JSP page ;o)
    <p>Integrating Oracle Forms into Oracle ADF Faces</p>
    Francois

    thx for the link. Good work

  • How to sync two iphone 4s to one itunes account on one PC?

    Hi
    Could you please tell me how to sync two iphone 4s to one itunes account on one PC? I successfully synced my husband's phone to my account ( he got his phone first) but my phone isn't showing up in devices. Very frustrating as he know can listen to all my music and I can't!!
    Thanks in advance

    Try this, How to use multiple iPods, iPads, or iPhones with one computer, http://support.apple.com/kb/HT1495

  • How to merge two WD components in one WD application?

    Hi SDN,
    Can any one tell me How to merge two WD components in one WD application?
    suppose i have two WD componets z_comp1 & z_comp2 now i want to use both these components in one WD application.
    Regards,
    Rahul.

    hi rahul...........
              you can use any number of wd components into one component.
    eg:
            consider you are having 2 components 'A' and component 'B' and you want to embed both into component 'C'.
           You can just click the 'Create' icon which will be present in the properties tab of the component controller.
           you mention the name of bothe components 'A' and 'B'.
            So now the interface controller of both the components are created in component 'C'.
           Now you can use the views present in both the components in component'C'.
    --regards,
      alex b justin

  • How to use Two main windows with in a page in script ?

    Hi any body explain me...
    How to use Two main windows with in a page in script ?
    with  header data in one main window,
    & Item data in other main window.

    HI..,
    u need to go for <b>SPLITTING THE MAIN WINDOW</b> !!!
    Main windows in page windows allow you to format text in multiple columns. Define an area in the page window, in which to position the main windows.
    Here is the procedure !!
    -->Create a page window and assign it to a page.
    Choose <b>Edit --> Main windows</b>.
    A dialog box appears.
    -->Enter values in the fields <b>Area width</b> and A<b>rea height</b> in accordance with the input guidelines for main windows.
    -->Enter values in the fields <b>Spacing</b> and Number in the <b>Horizontal group</b> if you want to use multiple columns. You can ignore the fields in the Vertical group.
    Determine how many columns and line areas are required for label printing. Then enter the corresponding values in the fields in the <b>Horizontal and Vertical groups</b>.
    -->The value in the field Left margin varies from main window to main window if multiple columns are used. The following applies:
    <b>
    Left margin of current column + Window width + Horizontal spacing = Left margin of next column</b>
    In label printing, the field Upper margin also varies from main window to main window:
    <b>
      Upper margin of current main window +  Window height + Vertical spacing = Upper margin of next main window</b>
    -->Enter a value in the field Start position.
    This is a counter. Enter a starting value which is equal to or greater than 1.
    -->The main windows are added to the list.
    -->Save your form.
    reward if it helps u...
    sai ramesh

  • Can I create multiple instances of  realplayer plug-in in one jsp page?

    I want to play meny video files in one jsp web page, these video files are to be played with the embeded plug-in of realplayer, each plug-in was linked(use its SRC property) a different video file. But, to my surprise, when I press the play button, every player played the same video file,not its specified file.
    I have no idea why it did so and what can I do?
    Whether can I create multiple instances of realplayer plug-in in one jsp page, that is to say, each instance is independent of others?
    thanks in advance!

    Generally speaking, Internet Explorer tries not to launch multiple versions of a plug-in. So what's happening is that you load the first video clip, and then before it has a chance to play, you load the second video clip into the same window. (It's like changing songs in WMA.)
    In some cases - this may not work for Real Player, but it's worth trying - if you spawn a new window through a hypertext link and then launch the plug-in in that window, IE will treat it separately. Otherwise, you could not, for example, run two Macromedia Flash applications from different web sites at the same time.
    Keep in mind that only one program can access the soundcard at a time, so Real Player may purposely "pause" or "cancel" other video streams until the active one finishes. If you were using the desktop version, selecting another video by any means aborts the currently running video (i.e., RP won't let you create a separate instance of it).
    The easiest solution is to create a wrapper JSP file that takes the name of the video clip, and plays it. Call that JSP and specify that it should be opened in a new window via the TARGET keyword in the anchor tag. Then hopefully RP itself won't block a second window from running.

  • How can I stop the execution on a JSP page and start it again

    Hi
    I am making a program that simulates how to manage transactions when accessing a database by using locks. I have run into a problem and I hope someone has the time to help me.
    When a user does an update the transaction commits and releases its locks when the program executes
    <%stmt.executeUpdate("commit!"); %>
    I need to put a break in to stop the program executing this statement, to illustrate the lock is set correctly.
    I have tried to put in an alert box but this does not prevent the rest of the java code being executed.
    I have tried to use prompt boxes, JavaScript functions, but these functions cannot have any java code in them.
    I have tried using the java.swing JOptionPane boxes but this didn?t work either
    I have tried to get input from the user but I don?t know how to retrieve this data on the same page. (As far as I know you have to use submit and even refresh the page or retrieve it on the next page).
    Does anyone know how I can stop the execution on a JSP page and start it again (on same page)
    Mette

    I already have another client (Tomcat jsp application) running and it throws a SQLException correctly when I don�t put in a commit=true statement and don't close the database connection.
    But the problem is how to get the code above to stop to illustrate I have set this lock.
    I have tried to use the JOptionPane but because my program is running in a web browser I cannot use the JOptionPane dialog box.
    I have tired using an alert box but it executes the commit statement before the alert box is dispayed. So this does not work
    While (i < 2)
    if( i==1)
    %>alert(�The transactions commits when you press Ok�); <% //what it to stop execution here
    else
    stmt.executeUpdate(�commit�);
    I am not using threads so I cannot use the sleep function.
    I am using mysql and have already configured it to detect deadlocks and how long to wait for locks.
    Thanks for your help
    Mette

  • Two managed beans in same jsp page

    Hello
    First this could be a stupid question, but i just can't find a solutions on this problem.
    I wondering that could it be a two managed beans in same jsp page, here is a example:
    index.jsp
    <t:commandLink disabled="#{listBean.currentPage == 1}" id="previous2" type="button" immediate="true" style="font-size:small" action="#{listBean.previousPage}">
    <h:outputText value="Edellinen" id="prev"/>
    </t:commandLink>
    <t:commandLink disabled="#{listBean.currentPage == listBean.totalPages}" id="next2" type="button" immediate="true" style="font-size:small;" action="#{listBean.nextPage}">
    <h:outputText value="Seuraava" id="next"/>
    </t:commandLink>
    then i have a dataTable like this:
    <t:dataTable value="#{customerListBean.customerBeans}"
    binding="#{customerListBean.dataTable}" preserveDataModel="true" style="text-align:left">
    My problem is that when i push a commandLink it doesn't refresh a dataTable. Does anyone know a solution here or is this just a impossible way to do it?
    Thanks for help.

    when i push nextPage (commandLink) it's call action
    and count a new range of dataset and after that it's
    calls a method which is declared on subClass and that
    method get a new data of database on given params.
    and put it on DataTable.
    So listBean is upper class and customerListBean
    extends on ListBeanNo, it doesn't work that way as you expected. You have created two independent instances. They doesn't communicate automatically with each other or so. Just use one CustomerListBean instance and call the inherited methods of ListBean on the #{customerListBean} managed bean instance.

  • How to retrieve the parameter names from a JSP page ? Urgent Please

    Hello,
    Can anybody tell me how to retrieve the parameter names from the JSP
    page. (without using getParameterNames() method.)
    The problem with the getParameterNames() method is I get the Jumbled output.
    I need it very badly
    With regards
    Ananth R
    email:[email protected]
    [email protected]

    Dear duffymo,
    My primary intention is to convert the JSP form information into a XML file.
    If I do not get the Parameter names in the correct order how can I maintain
    tag order in XML file.
    For ex: (JSP PAGE VIEW)
    Name--
    FirstName
    MiddleName
    LastName
    Address--
    Street1
    Street2
    City
    Country
    &so on
    (XML File to be generated)
    <Name>
    <FirstName>Value</FirstName>
    </Name>
    <Address>
    <street1>value</street1>
    </Address>
    & so on
    If I use getParameterNames() to get all the parameter names(Which form the tag names in the XML file ) the Enumeration object it returns will not be in the same order as the text fields in JSP.From this I can not construct a meaningful XML file.
    order means: Order of entry on the page, from top to bottom
    That's it
    Waiting for your responses

  • I want to post the values of the form in the same Jsp Page

    I want to post the values of the form in the same Jsp page.

    Was that a question? Or are you just informing the world of your grand intentions?
    But yeah, all you need to do is direct your action to the same page you're in. So, if this is your foo.jsp, it'd be something like...
    <%
    if(request.getParameter("bar") != null) out.println("Hello");
    %>
    <form method="post" action="foo.jsp">
       <input type="text" name="bar" value="baz">
       <input type="submit">
    </form>When you submitted your form, it would post the value to the same JSP page as you're already in, and print out Hello to the screen. "Hello" would not print out on the first visit, as the request would obviously not contain the parameter "bar" yet.

Maybe you are looking for

  • Voice memo won't show up in iTunes

    The short versoin: A just over 15 minute voice memo on my iPhone won't sync to my computer while other shorter voice memos do. It doesn't even show up on the playlist Voice Memos on my iPhone while plugged into my computer. I would like to back up th

  • How to measure the time of evolution of a signal in a graph and to compare this time measured with a known value?

    For my application, I am obliged to measure the time of evolution of a signal acquired (from T1 to t2) by an analogical entry of a module NI 9203, and to compare this value with a value known in order to judge if this time of evolution is correct or

  • HP PSC 1515 paper-feed problem

    Hi Our HP PSC 1315 has a paper-feed problem, but this does not appear to be a dirty roller: while I can hear motors whirring when the printer wants to feed in the paper, none of the visible rollers turn ― including the single pick-up roller ― and the

  • Erreur illustrator cs5

    Bonjour J'ai a l'essai la suite master cs5, tout fontionne bien ,sauf illustrator. lorsqure je le lance j'ai une fenetre qui me dit: "cette application ne prend pas en charge la langue actuelle du systeme d'exploitationouvrez le panneau de configurat

  • ORA-13207: incorrect use of the [More than 2D not supported] operator

    Oracle 8.1.7.4: The same query works in an Oracle DB on Linux and Windows, but in a Solaris it gives me the following error: cc_redes_met_coaxial@ORAG2> SELECT lot_f.lot_id id, ROUND(MDSYS.SDO_GEOM.SDO_DISTANCE(lot_geom.geometry, ped_geom.geometry, 0