I have a `jsp` page where I enter a username and click on a submit button.
On clicking this button, I post the username along with a hidden target page value to the other application. The other application does its processing and issues some cookies and redirects to the target page that I send. Is there any way to save the username that I entered in the form so that I can display it on the target page?

Please note that the application that I hit does not send any data.
Thanks

How are you redirecting to the other page?

Could you put the username in the a cookie?

No, I wouldn't want to do that. Redirection is done by standard using action in form.
Eg:

<form:form method="post" action="otherpage">
<input type="hidden" name="USER" id="USER" value="xyz">
<input type="hidden" id="TARGET" name="TARGET" value="xyz">
<input type="Submit" value="xyz">
</form:form>

How is redirection then done to "otherpage"?

I'm sorry, but I do not understand what you meant by "How is redirection then done to "otherpage"?". Otherpage not a jsp. Its a servlet in another application. I'm just redirecting using action.

Sorry I wasn't very clear. Let me summarise how I see things.

You have a page with a form which posts to "otherpage"

"otherpage" does some stuff and then "redirects to the target page that I send"

So my questionis how are you redirecting to this target page?

I do not redirect to the target page. "OtherPage" while doing its thing reads the hidden target variable from the request object and redirects to the target page.

You wrote:

"I do not redirect to the target page. "OtherPage" while doing its thing reads the hidden target variable from the request object and redirects to the target page."

The last part of this paragraph reads "and redirects to the target page".

Question - how do you redirect to the target page?

If you can't answer this time you will not hear from me again!

As mentioned in my initial post, OtherPage is not in my application. It is in another application. That application is redirecting to the target page. So, I do not know how they redirect.

Ok I see.

How about instead of posting directly to this page, you post to your own page and this then posts to the other page. This has given you an extra trip to your server then you can choose from a multitude of options for persisting data.

The new intermedary page I am suggesting could render a page back to the user with Javascript which makes it post as soon as its loaded. The content of this page could be something sensible to let the user know something is being processed.

Another option is to use ajax. When the user clicks submit, before posting to otherpage, make a call to the server and again choose from your persistence options.

Make sense?

Definitely makes sense, but how do we coincide this with the loading of the target page.
Also, I was thinking about session. Can we set it in a session? Like have a modelandview object and used addattribute to it?

"how do we coincide this with the loading of the target page" - I've explained how - do you undersand what it is I am suggesting?

User clicks button
Posts to your page - persist data here
Page is rendered to user with form
Form automatically submits via JavaScript to other page
Otherpage does its stuff and redirects back to you
On final page grab username from however you stored it.

Ok?

yes I got it. Thanks

Ok cool

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.