Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7178627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:57:32+00:00 2026-05-28T16:57:32+00:00

Im trying to prevent users to access special pages with a phaselistener. for that

  • 0

Im trying to prevent users to access special pages with a phaselistener. for that reason im trying to figure out on which page they try to access.

but my problem is, i only get the page they where before. not the actual page.

public void afterPhase(PhaseEvent event) 
{
    FacesContext fc = event.getFacesContext();
    System.out.println("test1" + fc.getViewRoot().getViewId());
}

and same here

public void afterPhase(PhaseEvent event) 
{
    FacesContext fc = event.getFacesContext();
    HttpServletRequest request = (HttpServletRequest) fc.getExternalContext().getRequest();
    String uri = request.getRequestURI();

    System.out.println("uri: " + uri);
}

why is that, and how do i get the pagename the user is trying to access? Not that one that they required one step before, or better the page they are coming from.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:57:33+00:00Added an answer on May 28, 2026 at 4:57 pm

    It is one step behind because that is the way sequence of HTTP POST request behaves. When you are navigating in JSF application via command buttons each request goes as a post request.

    Since you are protecting some resources make sure they are accessed via HTTP GET than you will get exact view id, this can be achieved as

    • User directly hits the url from address bar of browser.
    • After a post of jsf app redirect it to the resource instead of simple JSF navigation. POST-REDIRECT-GET pattern falls into this have a look here.
    • If you are showing some messages after each POST, you might need Flash map for that, which is new feature in JSF2, if you are on JSF1.x hard luck, you can implement flash if you want to.

    To conclude catch the view ids on HTTP GET request.

    Hope this helps…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to prevent information to be copied from a page (for non-technical users
I am trying to create a program similar to Folder Lock which prevents users
I'm trying to do this in a way that will prevent end-user browser security
Trying to prevent access to a specific file, not any files with a certain
Not that I'm trying to prevent 'View Source' or anything silly like that, but
I would like prevent anyone trying to access my website thro' code. Code in
I'm trying to get a PDF page that is within the context of my
I am trying to prevent data races in a multihreaded server. My problem is
I'm trying to prevent A HREF from actually opening the link, but to execute
I am trying to prevent any SQL injection in all my queries and would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.