You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by lucas owen <sr...@gmail.com> on 2012/06/29 14:03:52 UTC

Struts 1: two forms in a jsp possible?

Hi Struts 1 users:

I have a jsp to show information of an object, let's say its name, type,
length...
but now users can attach documents of that object and I've decided to add a
new form to accomplish this requirement:

------JSP:

<html:form action="object.do" method="POST">
<html:text property="name" size="10" maxlength="10"/>
<html:text property="type" size="10" maxlength="10"/>
<html:text property="length" size="10" maxlength="10"/>
</html:form>

<html:form action="insertObjDoc.do" method="POST"
enctype="multipart/form-data">
<html:file property="upldFile" size="40"/>
<html:submit value="UploadFile"/>
</html:form>

------struts-config.xml:

<action path="/object" type="ObjectAction"
name="ObjectForm" scope="request"  validate="true" input="/jsp/Object.jsp">
<forward name="object" path="/jsp/Object.jsp" />
</action>

<action
path="/insertObjDoc" type="InsertObjectAction" name="DocObjectForm"
scope="request"
validate="true" input="/jsp/Object.jsp">
<forward name="success" path="/jsp/InfoUploadDoc.jsp" />
</action>

so I only submit the bottom part of the JSP to insertObjDoc which only has
the uploaded file but the problem is that following exception arises:

javax.servlet.jsp.JspException: No bean found under attribute key ObjectForm

(I'm performing maintenance tasks and i dont want to touch first form (its
much more complex than what i've spotted), so i add a new one but i dont
know if this is possible with Struts 1)
thanks in advance

RE: Struts 1: two forms in a jsp possible?

Posted by Martin Gainty <mg...@hotmail.com>.
Hi Lucas its been at least 5 years since Ive touched struts-1 but i'm fairly certain there is separate Bean Java class you need to code which corresponds to name="ObjectForm" from the referenced <action tagso why not copy your java class from DocObjectForm to ObjectForm..rename all instances of DocObjectForm to ObjectForm in ObjectForm, compile and see if that flies Is there any reason (other than political) your shop is not upgrading to Struts 2.x? Paul?

Martin 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.

 > Date: Fri, 29 Jun 2012 14:03:52 +0200
> Subject: Struts 1: two forms in a jsp possible?
> From: sr.ilustre@gmail.com
> To: user@struts.apache.org
> 
> Hi Struts 1 users:
> 
> I have a jsp to show information of an object, let's say its name, type,
> length...
> but now users can attach documents of that object and I've decided to add a
> new form to accomplish this requirement:
> 
> ------JSP:
> 
> <html:form action="object.do" method="POST">
> <html:text property="name" size="10" maxlength="10"/>
> <html:text property="type" size="10" maxlength="10"/>
> <html:text property="length" size="10" maxlength="10"/>
> </html:form>
> 
> <html:form action="insertObjDoc.do" method="POST"
> enctype="multipart/form-data">
> <html:file property="upldFile" size="40"/>
> <html:submit value="UploadFile"/>
> </html:form>
> 
> ------struts-config.xml:
> 
> <action path="/object" type="ObjectAction"
> name="ObjectForm" scope="request"  validate="true" input="/jsp/Object.jsp">
> <forward name="object" path="/jsp/Object.jsp" />
> </action>
> 
> <action
> path="/insertObjDoc" type="InsertObjectAction" name="DocObjectForm"
> scope="request"
> validate="true" input="/jsp/Object.jsp">
> <forward name="success" path="/jsp/InfoUploadDoc.jsp" />
> </action>
> 
> so I only submit the bottom part of the JSP to insertObjDoc which only has
> the uploaded file but the problem is that following exception arises:
> 
> javax.servlet.jsp.JspException: No bean found under attribute key ObjectForm
> 
> (I'm performing maintenance tasks and i dont want to touch first form (its
> much more complex than what i've spotted), so i add a new one but i dont
> know if this is possible with Struts 1)
> thanks in advance