File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Problems w/ Tokens and Navigation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problems w/ Tokens and Navigation " Watch "Problems w/ Tokens and Navigation " New topic

Problems w/ Tokens and Navigation

Dale DeMott
Ranch Hand

Joined: Nov 02, 2000
Posts: 515
So I see some posts on here talking about Tokenizing Navigation as to avoid double posts etc. This is exactly what I want to do. I need 2 things. What code should I use and where should it go. While I got several versions of this code, I'd like to see some code that is generalized. Also does all the code go into the serlvet... or does some go into the jsp?

By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63867

I'm not sure what you mean by "Tokenizing Navigation" and a search of this forum brings up no prior usage of the term.

So what are you referring to?
[ March 30, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
Dale DeMott
Ranch Hand

Joined: Nov 02, 2000
Posts: 515
When navigation is built into a website its possible to hit the back button and be 'out of state'. An example might be if you end up creating an account, end up hitting submit more than once (or hit the back button and resubmit). A way to avoid this is to use the built in token code in order to avoid it. You might have code like this in your servlet in order to avoid double sumbits.

There are two parts to having the token created. The first part is the saveToken(request) part. This goes in your servlet. This creates a token (unique identifier) and puts it in the session. The second part
<html:form ..... >
takes the same token and puts it in the request. Problem is that you need to use this tag in order for this 'tokenizing' to work. It also seems if you have this tag, you also need a form bean. (aka a form associated w/the action). In my case, I don't need it. Its dynamic. A form bean gets in my way. My question is can I use the <html:form ..... > tag w/out using a form bean?
dema rogatkin
Ranch Hand

Joined: Oct 09, 2002
Posts: 294
I think so. What is form bean for?

Tough in space?, <a href="" target="_blank" rel="nofollow">Get J2EE servlet container under 150Kbytes here</a><br />Love your iPod and want it anywhere?<a href="" target="_blank" rel="nofollow">Check it here.</a><br /><a href="" target="_blank" rel="nofollow">Curious about generic in Java?</a><br /><a href="" target="_blank" rel="nofollow">Hate ant? Use bee.</a><br /><a href="" target="_blank" rel="nofollow">Need contacts anywhere?</a><br /><a href="" target="_blank" rel="nofollow">How to promote your business with a search engine</a>
Dale DeMott
Ranch Hand

Joined: Nov 02, 2000
Posts: 515
Quite frankly I don't need it. But it seems when I add the <html:form ... > tag it wants to have a form bean w/it.
I agree. Here's the link:
subject: Problems w/ Tokens and Navigation
It's not a secret anymore!