Hi, this is my 1st post...
I am facing problem in submitting two forms from one
JSP on one submit button..
I am using
Struts 1.1, MySql 5.1 and
Tomcat 6.20
Here is the detailed senario...
1. I have 2 tables Warehouse and Address in my MySql db,
2 . Warehouse table has address_id field as a foreign key which is a Auto_increment value in address table
3. I have a jsp called createWarehouse.jsp which contains two forms for warehouse and address with one submit button in address form,
4. I use a javascript to submit these two forms
5. As address id is the foreign key i need to persist address details 1st, so i set the action for address form and submit it through javascript
6. Then i take the address_id put it in a session object and refer it while persisting warehouse details.
7. Then from the same js function i submit warehouse form too
8. Every thing goes fine if i put a alert() statement between two form submissions
9. But if i remove that alert statement only address gets persisted
Here is wht i have figured out : In case if i don't put the alert statement in between.
1. When address form is submitted it goes to actionclass then to the daobean class and the queries are executed there,
2. But simultaneously the control goes forward in jsp file it goes to submit the warehouse form, this both process are going on parallely
3. And as in warehouse action it doesn't get the address_id from session it doesn't persist in warehouse table
But if i put the alert statement there is a pause between two submission and the address form submission gets enough time to get session object containing address_id.
I don't want to use window.timeout() as the transaction time can vary, even tried to put a while loop until i get the session attribute but dint work
Are my finding correct ???....
Please tell me a way around....Hoping to hear from Experts
Code is given below:--
JavaScript:-
createWarehouse.jsp :-
struts-config.xml
Awaiting Reply..Thanks in Advance
Cheers
S.!.D