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 8431307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:49:10+00:00 2026-06-10T05:49:10+00:00

In my web app, when the session expires and a user initiates a request

  • 0

In my web app, when the session expires and a user initiates a request (full page or AJAX), the user is redirected to the login page with a message that the session expired. The problem is, when the login page is left open long enough for the session to expire and the user attempts to login, the user is redirected to the login page with a message that the session expired.

I came across this solution, but it is for JSF 1.x and won’t work with JSF 2. So I started building my own:

public class LoginViewHandler extends ViewHandler
{
    public LoginViewHandler(ViewHandler parent)
    {
        this.parent = parent;
    }

    @Override
    public Locale calculateLocale(FacesContext context)
    {
        return parent.calculateLocale(context);
    }

    @Override
    public String calculateRenderKitId(FacesContext context)
    {
        return parent.calculateRenderKitId(context);
    }

    @Override
    public UIViewRoot createView(FacesContext context, String viewId)
    {
        return parent.createView(context, viewId);
    }

    @Override
    public String getActionURL(FacesContext context, String viewId)
    {
        return parent.getActionURL(context, viewId);
    }

    @Override
    public String getResourceURL(FacesContext context, String path)
    {
        return parent.getResourceURL(context, path);
    }

    @Override
    public void renderView(FacesContext context, UIViewRoot viewToRender)
            throws IOException, FacesException
    {
        parent.renderView(context, viewToRender);
    }

    @Override
    public UIViewRoot restoreView(FacesContext context, String viewId)
    {
        UIViewRoot viewRoot = parent.restoreView(context, viewId);

        if (viewRoot == null && viewId.equals("/login.xhtml"))
        {
            parent.initView(context);

            viewRoot = parent.createView(context, viewId);
            context.setViewRoot(viewRoot);

            try
            {
                buildView(context, viewRoot); // Compile error!
            }
            catch (IOException e)
            {
                log.log(Level.SEVERE, "Error building view", e); 
            }
        }

        return viewRoot;
    }

    @Override
    public void writeState(FacesContext context) throws IOException
    {
        parent.writeState(context);
    }

    private ViewHandler parent;
}

However, there is no method called buildView. I’m not sure what it does, why it’s needed and what I should replace it with. Any ideas?

  • 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-06-10T05:49:12+00:00Added an answer on June 10, 2026 at 5:49 am

    It has been moved to ViewDeclarationLanguage#buildView() as this step is decoupled from the view technology used (Facelets, JSP, JavaVDL, whatever).

    context.getApplication().getViewHandler()
        .getViewDeclarationLanguage(context, viewId).buildView(context, viewRoot);
    

    It’s by the way simpler to extend ViewHandlerWrapper instead. This way you don’t need that bunch of delegate methods.

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

Sidebar

Related Questions

i have web app and on session timeout and user interaction on the page,
I am creating a web app which uses jQuery to authenticate: $.ajax({ url: /session/create?format=json,
In my .NET web app, I keep basic user info in a user session
In my web app after a user logs in a new session is created
I want to use session object in my web app.I want to store some
When you log out of a web app, should ALL your session be logged
I am trying to implement a Session-Per-Conversation pattern in a JSF2-Spring-Hibernate Web App so
I have implemented a web app using session state management as per the instructions
I'm writing a web app with multiple jsp files wit a session timeout of
In an ASP.NET web app, using Integrated Windows Authentication, is the session tied to

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.