File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cancel button must go back to the previous jsp page

 
Sumithab Baskaran
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

Consider this:

There are 3 jsp pages/forms(A, B, C) and respective action classes.

JSP A has two buttons - Comments and Cancel
JSP B has two buttons - Comments and Cancel

JSP C is the comments page - has a cancel button

When the C page is accessed from A page, the cancel button in C must go back to A.
When the C page is accessed from B page, the cancel button in C must go back to B.

What is the best way to do this in struts?

Thanks in advance.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd just put a "returnTo" property on my form bean for C, have JSPs A and B pass returnTo as a parameter to C. Then the C action can return to either A or B based on the value of the parameter.

Another way to do this would be to define two different action mappings, (commentsA and commentsB) both of which call the C action class. Each mapping would have a local forward named "cancel". In commentsA, the forward would point to JSP A, and in commentsB, the forward would point to JSP B. That way, when the C action class returns the "cancel" forward, it goes to different JSPs depending on which action mapping invoked the class.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic