Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Display a Form on a button click using struts tags

 
Vidya Gupta
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am having a small doubt , that is in my page am having 3 buttons and i want to display a different form when i click on each button. I want to do this by single jsp. Am having a little bit confusion in doing this.

<table align="left" border="0" cellspacing="0" cellpadding="1">
<tr>
<td>
<input type="button" value="button1" onclick="action"/>
<input type="button" value="button2" onclick="action"/>
<input type="button" value="button3" onclick="action"/>
<input type="button" value="button4" onclick="action"/>
</td>
</tr>
</table>

Here for each button it is going to different action methods, in that action method i am writing "return mapping.findForward("") " statement. This statement will forward the action to the same jsp again that contains buttons. Now i want to create a form on button click in the same jsp. am little bit confused that where to write the code to create a form in theis jsp..


Thanks In Advance,
Vidya
 
Yogesh Lonkar
Ranch Hand
Posts: 94
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from what ever i understood you want to display a form respected to the button clicked by user.
you can add this to your JSP


and inside your struts.xml file



inside your action class
 
Vidya Gupta
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

No.. i don't want to use multiple form:acion attributes in jsp..

My JSP looks like below,

display.jsp
-------------




 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic