Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8171477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:28:20+00:00 2026-06-06T21:28:20+00:00

I have a following question. We have an application that is a basically a

  • 0

I have a following question. We have an application that is a basically a set of JSPs and action classes that control the interaction with the user. The actions set up some parameters required for the page to display properly. The urls in the system always contain the name of the event which defines which page we should go next.

Now, almost every page has a Cancel button that should lead to the previous page. From the start each cancel button url was strictly defined, but eventually, as the system grew larger and larger, it turned out to be quite hard to program the logic for this button so that it would lead exactly to the previous page.

For example, suppose we have three pages, A, B and C. Page A has a link leading to page B, and B has a link leading to C. Therefore C has an url with even leading to B (and also it contains the key of the entity to display on B). However, suppose page A was modified and now also has a link on C. Now we need to check on C page from there we came and set the URL appropriately, and the logic becomes pretty mixed.

So, I proposed to my team the following solution. The user session should contain a special object called the CancelStack. Every action, that leads to the page, should push it’s url inside the stack (containing the event and some additional data that is required). On every page the cancel button should now have an url leading to a special event, called cancelStack.

What the cancelStack action does is this:

  • Retrieve the cancel stack from the session.
  • Pop the last url and DO NOT use it.
  • Pop the url again and redirect to that URL.

Why do we retrieve the last url without using? Suppose we have pages A and B, A leading to B. Action for A places it’s url inside the stack, and this should be the cancel url for the B page. Now, action for B places it’s url inside the stack. Therefore I pop it without using, and then pop the first url, redirect to A action, and this action adds the A url again to the stack (therefore stack size decreases only by 1, not by 2).

It seems like a pretty good scheme, however it seems rather strange that the top element of stack is popped without using. Therefore I have a question. Is there any design patter in order to store the sequence of URLs inside the session in order to organise cancel buttons properly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T21:28:22+00:00Added an answer on June 6, 2026 at 9:28 pm

    What you did seems reasonable to me. To be honest I can’t think of a design pattern addressing your issue right now, but I think if besides the cancelStack you keep a reference to the currentURL so that you push the currentURL to the stack only if you don’t end up in a cancel page you will get rid of the extra pop that annoys you.
    Otherwise you just pop the top of cancelStack.
    E.g. in your example:

    Suppose we have pages A and B, A leading to B…

    currentUrl is A. Action for A is not cancel so currentUrl i.e. A is pushed to the cancelStack. Then it is action for B and currentURL is B but action is cancel so B is not placed in the stack. So the top of cancelStack is A (while currentUrl is B). So if you pop the cancelStack you retrieve A (no extra pop needed)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A small - little question. I have seen many application having buttons like following.
I have the following question. I have a set of Fortran90 source files, most
I have been assigned a project to develop a set of classes that act
I have a user-space application that generates big SCSI writes (details below). However, when
so here's a quick question. Basically I'm making an express application that connects to
I have following question on adobe omniture How we can register an iPhone app
I am new to Spring Batch. I have following question. I am using Spring
I have the following question, and it screams at me for a solution with
I have the following question. How can I print an output file line by
I have the following question about JPA: Can I save the order of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.