wood burning stoves 2.0*
The moose likes JSP and the fly likes How to merge two forms in a single jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to merge two forms in a single jsp" Watch "How to merge two forms in a single jsp" New topic

How to merge two forms in a single jsp

Ravi Kumar

Joined: Aug 28, 2008
Posts: 18
I have a jsp which is having two forms as below

<form name="frm2" method="post" action="../servlet/com.infy.cis.ui.marketing.CampaignSave">
<Input type="text" name="test1" value=">
<Input type="text" name="test2" value=">

<form name="attachmentForm" method="post" enctype="multipart/form-data" action="../servlet/com.infy.cis.ui.common.CampaignAttachmentWriter">
<input class="BrowseFile" name="filename" onchange="addAttachment();" onkeypress="return uploadAttachmentOnEnter()" type="file">

Now i need to merge these two forms to make my code work properly. If iam combining this code in one form and enctype="multipart/form-data" for the form it is not getting the values of text fields. If i removed the enctype it is not getting the file contens of the data.

Please help me how to resolve the issue as i need to merge these two forms into single form.

Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
The sexiest way would be using the Struts 2.0 framework. It does all the parsing and data transfer automatically to keep you away from these details.

JDBCSupport - An easy to use, light-weight JDBC framework -
David Newton

Joined: Sep 29, 2008
Posts: 12617

If you're using a multipart form then you have to deal with the request: most people use some form of a multipart request wrapper (like the one in Apache commons, but I'm sure there are a million others). Many/most webapp frameworks hide this complexity from you--are you using straight servlets?

You're not using the invoker, are you? That's bad, IMO.
Ravi Kumar

Joined: Aug 28, 2008
Posts: 18

Iam working in a company where they have product from past 15 years and they have designed like this and i need to merge this forms using jsp, servlets,js. Is there any way to resolve the above problem?

Please help me.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60800

See the JSP FAQ on file uploading.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
It is sorta covered in the JavaRanch Style Guide.
subject: How to merge two forms in a single jsp
Similar Threads
file uploading
File uploading and data collection problem
File Upload
About form submission