It's not a secret anymore!
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Bookmarked page issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Bookmarked page issue" Watch "Bookmarked page issue" New topic

Bookmarked page issue

Tome Wagese

Joined: Jan 13, 2007
Posts: 24
Hello Friends,

I am sure you have run across this issue.
How can I prevent page from being forwarded to bookmarked page and force users to Be in default welcome page after first logon.

I do have the <welcome-file-list> set up correctly in DD but if the users use their bookmarked link, it is ignored.

Deepak Bala

Joined: Feb 24, 2006
Posts: 6662

What do you mean by that ? You want the user to see the welcome page even if he requests for some other page on the first try (through a bookmark) ?

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Doyle Matt
Ranch Hand

Joined: Jul 05, 2004
Posts: 76
If i understand you question correctly.. here's an answer.

Use a filter to force to check if a session is existing on the client side. If the session is just new or non existant then redirect to your desired page. However this might be a problem if you have login and logout.

Another solution would be to check for the "referrer" header.

SCJP 1.4
Tome Wagese

Joined: Jan 13, 2007
Posts: 24
Hi John,
Thank you so much for the reply.
Here is what my problem.
Normally users come to login.jsp and with proper authentication user is forward to default.jsp
But some users have the protected pages bookmarked in their browser so when they login, request is forwarded to the bookmarked page instead of default.jsp.
Tome Wagese

Joined: Jan 13, 2007
Posts: 24
Thanks Doyle
I'll try that.
Tome Wagese

Joined: Jan 13, 2007
Posts: 24
I tried several methods to get around this issue and nothing seem to be working perfectly.
If anyone has and example of working (tested) piece of code, that would be very helpful.
I am using form authentication provided by Tomcat 6.x container.

I am not planning on putting little piece of code in every pages to check for authentication session either.
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

It doesn't sound like you tried a filter. If you did, post it here and we'll kindly let you know why it isn't working.

A good workman is known by his tools.
Tome Wagese

Joined: Jan 13, 2007
Posts: 24
I did try using filter Marc.
But here is the scenario.
Since Tomcat 6.x did not kick off filter for j_security_check,
I made my own servlet (AppGroupInit) that adds additional session variable to the successful logins and forwards it to the defaut.jsp
<filter-class>AppGroupSwitch </filter-class>
<filter-name>AppGroupSwitch </filter-name>
Since I have only one file referenced in welcome-file-list, everything is smooth when uses do not use bookmarked link.
But my problem is if uses has bookmarked other pages then AppGroupInit servlet never runs and uses is directly forwarded to whatever page they had bookmarked.
I agree. Here's the link:
subject: Bookmarked page issue
It's not a secret anymore!