wood burning stoves 2.0*
The moose likes Struts and the fly likes link another jsp page when button clicked- how- help urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "link another jsp page when button clicked- how- help urgent" Watch "link another jsp page when button clicked- how- help urgent" New topic
Author

link another jsp page when button clicked- how- help urgent

Liz Brown
Ranch Hand

Joined: Oct 22, 2002
Posts: 112
HI,
I have a form with 3 buttons on my jsp. in struts config i have put the <forward name="validate" path"/validatefile"/>

validatefile path is to go to another action-jsp.
is something wrong?
the name is name of button on jsp. In actionclass i have just execute method. when user clicks on button1 how do we take him to another jsp?
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
Is the button part of a form?

you need an html:form tag with an attribute action="yourActionPath"
or alternately an html:link with an attribute action="yourActionPath"

the action path should take your program to an action class where processing is done then after that action class returns a value which determines what jsp or page definition you go to next (these are the forward tags nested inside the action tags in the struts-config file).

This pretty fundamental to the way struts works, form/link submission -> action class -> page/jsp(with forms/links) -> action. Just all the parts represented by -> are maintained inside the struts-config.

I'd recommend spending 2-3 hours just reading a book/website.
Liz Brown
Ranch Hand

Joined: Oct 22, 2002
Posts: 112
ok. Do i need to put any code for each button in action class?
Or just forward tag in struts will take name of button and path to the action or jsp i mention.
I have got it until here, however i am not sure if i need to add code to hnadle each button in actionclass.
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
Depends on what each button is doing. Is each button assocciated to the same form? or same link? If each button is associated to its own form then each one will have its own action class. However if all three buttons are associated to the same form/action you need to do something that will let your action class differentiate between which one was pushed (assuming you want them all to do different things). For me the easiest thing to do was add a hidden field to the form who's value I changed with javascript to denote which button was pressed (and then submit the form).

-Tad
Liz Brown
Ranch Hand

Joined: Oct 22, 2002
Posts: 112
page 1 has 3 buttons, each should go to different paths(action-form-jsp)

can you please tell me more about button names and forward action if i have to write in struts-config.

Example:
I have 3 buttons each are submit type and if I have different names for them. How do we generally wrtie this code to mention these buttons with struts tags and html:link ? can I do this way mentioning in struts-config.

Do we generally write any methods inside action class to foward the buttons to another path?
Florian Kammermann
Greenhorn

Joined: Jan 22, 2005
Posts: 8
Perhaps the LookupDispatchAction can help you. with this Action you can specify for each form-button a separate method to be called in an ActionClass (must be inherited from LookupDispatchAction).

http://www.jguru.com/faq/view.jsp?EID=900642

http://husted.com/struts/tips/003.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: link another jsp page when button clicked- how- help urgent
 
Similar Threads
call one jsp's java script function to another jsp's javascript function
Action set for submit button
click on button-->save data-->go to another page?
JSP and Radio Buttons
Display a pdf in another jsp