Announcement Announcement Module
Collapse
No announcement yet.
Setting multiple forward´s Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting multiple forward´s

    Hello everyone. What I want to do aparently is very simple. I want to set other redirect strategy to ACEGI. For example, in one situation, I want that ACEGI goes to a.html page, in other to b.html page...

    I´ve tried to implement the AccessDeniedHandler interface and setting MyImpl in the xml file, for example:


    Code:
    <bean id="exceptionTranslationFilter" class="org.acegisecurity.ui.ExceptionTranslationFilter">
    		...
    		<property name="accessDeniedHandler">
    			<bean class="package.MyImpl">
    				<property name="errorPage" value="/Failure.ssp"/>
    			</bean>
    		</property>
    	</bean>
    But it isn´t working. My code for the handle() method:

    Code:
    public void handle(ServletRequest request, ServletResponse response,
    			AccessDeniedException accessDeniedException) throws IOException,
    			ServletException {
    		
    		if (errorPage != null) {
    			((HttpServletRequest) request).setAttribute(ACEGI_SECURITY_ACCESS_DENIED_EXCEPTION_KEY,accessDeniedException);
    boolean test = true; //only for the example
    String forward = "a.html";
    if (test) {
      forward = "b.html";
    }
    			RequestDispatcher rd = request.getRequestDispatcher(forward);
    			rd.forward(request, response);
    		
    		}
    		
    		if (!response.isCommitted()) {
    
    			((HttpServletResponse) response).sendError(
    					HttpServletResponse.SC_FORBIDDEN, accessDeniedException.getMessage());
    		}
    	}
    Please someone help I´ll really appreciate

    John.

  • #2
    Hi John..

    Would you just explain in which cases you want to forward to different pages. I mean to say do you want to forward to different pages depending on the exception occured.
    For e.g., let say when BadCredentialsException is thrown you want to forward to some a.jsp/a.html.

    Amol.

    Comment

    Working...
    X