my dog learned polymorphism*
The moose likes Struts and the fly likes How to avoid using formbean and redirect to another JSP ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to avoid using formbean and redirect to another JSP ?" Watch "How to avoid using formbean and redirect to another JSP ?" New topic
Author

How to avoid using formbean and redirect to another JSP ?

Sreedevi Vinod
Ranch Hand

Joined: Jan 17, 2005
Posts: 117
In one of my JSP pages, I need to press a button and move to another JSP. There is no business logic to put in an action, nor any request parameters to be captured by the form bean. I know that I can forward using html:link and ForwardAction class, but I want to do this from a button press and not from a link. How do I do that ?

Thanks
Devi
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
One way to do it would be like this:

<html:button property="myButton" value="click me" onklick="location.replace('myOtherPage.jsp')" />


Merrill
Consultant, Sima Solutions
Sreedevi Vinod
Ranch Hand

Joined: Jan 17, 2005
Posts: 117
Thanks, but I didn't want to link directly from one JSP to another, since thats not a good practice. Every redirection should happen through the controller. So finally I used a blank form bean along with ForwardAction and posted to it using html:form. That worked, but now I have another problem.
I have a flash movie on the JSP page to which I'm redirecting. This flash movie is not playing when I redirect like this through the ActionServlet.
The page keeps loading as shown by the progressbar on the browser, but never completes rendering. The title and text at the top does appear. Why could this be happening ? However, it loads the page and plays the flash movie immediately when I provide a direct link to the JSP page itself.
Please advice.

Thanks
Devi
Manesh Kumar
Ranch Hand

Joined: Mar 21, 2006
Posts: 94
You can use..



Then using Javascript (write within the function which will be called by click of the button) to redirect to the url


Manesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to avoid using formbean and redirect to another JSP ?
 
Similar Threads
multiple forms in struts
Jsp <html:link building of an url
How to open another browser window in a jsp
Action set for submit button
JSP and Radio Buttons