Customizing Viewpoint > Displaying a custom site maintenance page

3.9.1 Displaying a custom site maintenance page

You can create a custom .jsp solution to deal with site maintenance times.

To display a custom site maintenance page

Import the following into a new .jsp file to replace the normal application:

<%@ page import="com.cri.security.server.*" %>

<%@ page import="java.security.*" %>

<&@ page import="java.util.*" %>

<%@ page import="javax.servlet.*" &>

Add the following code in that same .jsp to authenticate a user:

<%

    boolean isAuthorized = false;

        ViewpointUser user = SecurityService.get().authenticate(request);

        Permissions permissions = user.getPermissions();

        List<Permission> permissionsList =

            Collections.list(permissions.elements());

        for (Permission permission : permissionsList ) {

            // In the following line, match the quoted text with any

            permission to have that permission

            // be the permission used to allow the user into the site.

            if ("maintenance.user".equals(permission.getName())) {

            isAuthorized = true;

            }

        }

    if (!isAuthorized) {

        // If the user has the correct permission, display the normal

        login page

        // If the user does not have the correct permission, display the

        "under construction" page.

    %> <jsp:forward page="maintenance.jsp" /> <%

}

%>

This code can be customized further to forward the user to any location the administrator desires based on the <jsp:forward page="targetPage.jsp"> element.

Related topics