File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts - forced welcome page? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts - forced welcome page?" Watch "Struts - forced welcome page?" New topic

Struts - forced welcome page?

Clifford Adams
Ranch Hand

Joined: May 12, 2004
Posts: 50
Is there a way to force all users of my struts app to start at the welcome page? for example, If someone bookmarks http://www/projects/ it will instead force them to go to http://www/projects/index.jsp

Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

You can use tokens to flag valid submissions. See the Struts JavaDocs for Action.isTokenValid(), Action.saveToken(), Action.resetToken(). See also this article

Here's the logic:

if (!isTokenValid(request)) {
return mapping.findForward("home"); // where "home" is a global forward

You might also check for some object in the session scope that indicate that a user has properly logged in to the application. If the object is not there, you'd forward to the home page.
[ November 30, 2004: Message edited by: Junilu Lacar ]

Junilu - [How to Ask Questions] [How to Answer Questions]
Tony Yan
Ranch Hand

Joined: Apr 10, 2002
Posts: 170
You probably want to do it in a Filter so that you don't have to change much code in all Actions.

Tony Yan<br /> <br />IBM Certified Developer XML and Related Technology<br />Sun Certified Web Component Developer For J2EE Platform<br />Sun Certified Programmer For Java 2 Platform
Clifford Adams
Ranch Hand

Joined: May 12, 2004
Posts: 50
Can you give an example of doing this in a filter? I haven't used them before.

I agree. Here's the link:
subject: Struts - forced welcome page?
It's not a secret anymore!