Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts - forced welcome page?

 
Clifford Adams
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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/loadProject.do?id=45 it will instead force them to go to http://www/projects/index.jsp

Thanks!
 
Junilu Lacar
Bartender
Posts: 7553
52
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Tony Yan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably want to do it in a Filter so that you don't have to change much code in all Actions.
 
Clifford Adams
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you give an example of doing this in a filter? I haven't used them before.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic