Search Results

Search found 2 results on 1 pages for 'user292662'.

Page 1/1 | 1 

  • Redirect to another action in an interceptor in struts 2

    - by user292662
    I am currently in the process of learning Struts 2 and I am currently building a simple application where unverified users are redirected to a login form. I have a login form and action functional which takes the users credentials, verifies them and stores a User object in the session however I am now trying to prevent access to pages before the login has taken place and I am trying to do this with an interceptor. My problem is that I have written an interceptor that checks whether the User object has been saved in the session but if it has not I want to redirect to the login page and can't find any way of doing this without bypassing struts and using the HttpServletResponse.sendRedirect method Configuration: <package name="mypackage" extends="struts-default" namespace="/admin"> <interceptors> <interceptor name="login" class="my.LoginInterceptor" /> </interceptors> <default-interceptor-ref name="login"/> <action name="login" class="my.LoginAction"> <result name="input">/admin/login.jsp</result> <result name="success" type="redirect">/admin</result> </action> <action name="private" class="my.PrivateAction"> <result>/admin/private.jsp</result> </action> </package> The interceptor code: @Override public String intercept(ActionInvocation inv) throws Exception { Map<String, Object> session = inv.getInvocationContext().getSession(); Object user = session.get("user"); if(user == null) { // redirect to the 'login' action here } else { return inv.invoke(); } }

    Read the article

  • Old fashioned html onclick return false doesnt in IE work when jquery script included

    - by user292662
    Ok, so im quite new to jquery but found this bizzar problem just now, If we ignore jquery for a second and consider this scenario, if i have two links like below both with an href and both with and onclick event. The first link will not follow the href because the onclick returns false, and the second link will because the onclick returns true. <a href="/page.html" onclick="return false;">Dont follow</a> <a href="/page.html" onclick="return false;">Follow</a> This works just hunky dory in every browser as it should, the thing is, as soon as i include the jQuery script on the page this stops working in all versions of IE which then always follows the href whether the onclick returns false or not. (it continues to work fine in other browsers) Now if i add an event using jquery and call .preventDefault() on the event object instead of doing it the old fashioned way this behaves correctly, and you may say, well just do that then? But i have a site with thousands of lines of code and i am adding jquery support, i dont want to run the risk that i might miss an already defined html onclick="" and break the website. I cant see why jQuery should prevent perfectly normal javascript concepts from working, so is this a jQuery bug or am I missing something?

    Read the article

1