Announcement Announcement Module
Collapse
No announcement yet.
how to redirect to an error page Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to redirect to an error page

    Bonjour,
    Hi, I use spring and jsp in my application. I cannot redirect to an error page


    Here is my controller

    Code:
        public ModelAndView index(final HttpServletRequest request, final HttpServletResponse response) throws ServletRequestBindingException, DatatypeConfigurationException {
            // something
            boolean isOnTheGoodSession = accountManagementService.checkRandomNumber();
            if (isOnTheGoodSession) {
                 // something
                return new ModelAndView("index", "model", model);
            } else {
                // my error page is newBrowser.jsp
                return new ModelAndView("../../newBrowser", "model", model);
            }
        }
    I use spring security
    here is a part of the xml file

    Code:
        <http entry-point-ref="authenticationEntryPoint" disable-url-rewriting="true">
            <!--Restrict URLs based on role-->
            <intercept-url pattern="/css/**" filters="none" requires-channel="https"/>
            <intercept-url pattern="/js/**" filters="none" requires-channel="https"/>
            <intercept-url pattern="/ext/**" filters="none" requires-channel="https"/>
            <intercept-url pattern="/img/**" filters="none" requires-channel="https"/>
            <intercept-url pattern="/userguide/**" access="IS_AUTHENTICATED_ANONYMOUSLY" requires-channel="https"/>
            <intercept-url pattern="/login.htm*" access="IS_AUTHENTICATED_ANONYMOUSLY" requires-channel="https"/>
            <!--  requires-channel="https"/> -->
            <intercept-url pattern="/login.jsp*" access="ROLE_RDE" requires-channel="https"/>
            <intercept-url pattern="/user/**" access="IS_AUTHENTICATED_ANONYMOUSLY" requires-channel="https"/>
            <intercept-url pattern="/secure/**" access="ROLE_RDE" requires-channel="https"/>
            <intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" requires-channel="https"/>
            <custom-filter position="FORM_LOGIN_FILTER" ref="authenticationFilter"/>
            <session-management invalid-session-url="/reconnection.htm">
                <!--<concurrency-control max-sessions="1" error-if-maximum-exceeded="true"/> -->
            </session-management>
            <logout logout-success-url="/login.htm"/>
        </http>
    and my application tree (I tried to put my error page "newBrowser.jsp" in 2 locations but without success) is at the following address


    http://imageshack.us/photo/my-images...ewbrowser.png/

    Thank you in advance for your answers

  • #2
    Then redirect instead of passing a view name... Redirect to the full url, normally you return a view name which gets its name generated by the ViewResolver.

    Comment


    • #3
      Hi Marten and thanks a lot for your answer. With your way I have effectively the url displayed in the address bar, but it seems that it doesn't load the page. What is strange is that I have another page index.jsp exactly at the same level in my tree and this jsp page is displayed when I type the url in the address bar while my error page newBrowser.jsp is not displayed with the proper url

      Comment


      • #4
        Hi again,

        I forgot to give the code of my error page
        Here is

        <%--
        Author: Xavier Flamant
        Date: Feb 27, 2010
        Time: 14:45:00 PM
        eClinica SPRL 2009� All Rights Reserved
        --%>

        <%@ include file="/WEB-INF/jsp/includes/taglibs.jsp" %>
        <html>
        <head>
        <link rel="stylesheet" type="text/css" href="<c:url value='/ext/resources/css/ext-all.css'/>"/>
        <script type="text/javascript" src="<c:url value='/ext/adapter/ext/ext-base.js'/>"></script>
        <script type="text/javascript" src="<c:url value='/ext/ext-all.js'/>"></script>
        <%@ include file="/WEB-INF/jsp/includes/extjs.jsp" %>
        <link rel="stylesheet" type="text/css" href="<c:url value='/ext/resources/css/yourtheme.css'/>"/>
        <link type="text/css" rel="stylesheet" href="<c:url value ='/css/login.css'/>"/>
        <title>
        <spring:message code="login.login"/> -
        <spring:message code="application.name"/>
        <spring:message code="application.version"/>
        </title>
        <link rel="icon" href="./img/favicon.ico" type="image/x-icon"/>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta http-equiv="expires" content="Mon, 22 Jul 2002 11:12:01 GMT"/>
        <meta http-equiv="cache-control" content="no-cache"/>
        <script type="text/javascript">
        alert('ca passe');
        Ext.onReady(function () {
        console.log('document.URL='+document.URL);
        var newBrowser = new Ext.Window({
        id: 'newBrowserId',
        layout:'fit',
        width:400,
        height:210,
        plain:true,
        modal:true,
        title:'<spring:message code="application.security.warning"/>',
        iconCls:'warningMessage',
        items:{
        xtype:"fieldset",
        autoHeight:true,
        items:[
        {
        xtype:'displayfield',
        anchor:'100%',
        hideLabel:true,
        value:<spring:message code="application.security.onlyOneTab"/>'
        }
        ]
        },
        buttons:[
        {
        text:'<spring:message code="action.OK"/>',
        disabled:true,
        handler:function () {
        newBrowser.close();
        }
        },
        {
        text:'<spring:message code="application.action.openNewBrowser"/>',
        handler:function () {
        // var myRef = window.open('url');
        newBrowser.close();

        }
        }
        ]
        });
        newBrowser.show();
        });


        </script>
        </head>
        <body>

        </body>
        </html>

        Comment


        • #5
          Hi,
          I now can display my error page.

          I in fact had errors in inclusion files

          I have to check now that evrything is going well on both side together (client+server)

          Comment

          Working...
          X