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

  • Home
  • SEARCH
  • 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 8196301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:26:03+00:00 2026-06-07T05:26:03+00:00

I have a home-grown MVC implementation. A ControllerServlet like so: /controller?cmd=EditUser&userid=55 From this URL,

  • 0

I have a home-grown MVC implementation. A ControllerServlet like so:

/controller?cmd=EditUser&userid=55

From this URL, the controller creates a EditUserCommand.class instance and calls an execute() method which returns the result page (ex. user.jsp) to display.

The controller servlet then does a …

getRequestDispatcher(resultPage).forward(request, response);

… and the resulting page is shown.

One of the things the controller does is set messages (error, info, and so on) as request attribtues. For example:

request.setAttribute("infoMessage", "User was edited successfully.");

And that message gets pulled out of the request in the user.jsp page and displayed.

Works fine.

Now here comes my problem.

Sometimes my commands don’t return a page like user.jsp but return a URL like cmd=ShowUser&userid=55 for the result. This is because there might be things I want to check before displaying the final page, like permission to view the user and so on.

When I do this the “infoMessage” I placed in the request never appears because the result is a URL that makes a new call to the servlet, which is a new request. The new request doesn’t maintain the request attributes from the first request; which makes sense, I just didn’t forsee this happening.

How can I make my request variable “stay alive” until it’s actually displayed on the final page that results from the original request?

Any suggestions or advice are appreciated. Just FYI, I can’t re-write the entire app to go to something like Struts, Spring MVC, of JSF. It’s not an option.

Thanks!

Rob

  • 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-07T05:26:04+00:00Added an answer on June 7, 2026 at 5:26 am

    You may be giving a simple example, but your control flow causes the “Resend” Error, perhaps? Basically, after making any change to the data, the controller must immediately do a “Get” via a redirect and the screen should be displayed completely stateless.

    Please take a look:
    http://en.wikipedia.org/wiki/Post/Redirect/Get

    As such, Attributes are not a great help. What you may want to consider is, maintaining a Bean/Object for every login user, and persist this object in a LRU cache (JCache or MemcacheD), and retrieve it on every entry to the application. Once you have that, you can maintain a pseudo-state such as previous results in that object.

    In any case, using Attributes to retain state will severely constrain your options. You need to have a more generic flexible routing-independent mechanism.

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

Sidebar

Related Questions

I have a home grown web server in my app. This web server spawns
I'm trying to adapt my GWT web application from my home-grown MVC to GWT
What is the best way to have your own home-grown Java-based implementation of Aspect-Oriented-Programming?
I have a home-grown HTTPS server that serves up simple files (it's embedded within
I have the following home-grown jquery plugin: (function($) { $.fn.defaultButton = function(button) { var
I have folder home/admin. In this folder there is index.php. When i access to
i have view like 'home/details/5', it can be access by anonymous user. but there
For a while at my company we've used a home-grown ObjectPool<T> implementation that provides
I have been tasked with doing some planning and research for a home grown
I have a home-grown automated build script in the form of a DOS batch

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.