Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Sign out options

    Isomorphic,

    is there are any ways to achieve sign out/log out the session using smartGWT API's(server API's)? I need to clear all cookies associated with the session and redirect to my login screen..

    Direct me to closest solution to achieve my needs...

    Thanks,
    Yathish

    #2
    You can only clear cookies in the context of an httpRequest from the client. The core servlets APIs have the APIs necessary to clear cookies.

    Comment


      #3
      Ok. This is same with Singout/Logout? or are there are any gwt/smartGWT specific API's?

      If that is the case, we have to call a DMI on click of that label.. Any other ways?

      Comment


        #4
        A server call is required as previously noted. A DMI from a label is one of many options, but yes, that's a typical approach.

        Comment


          #5
          Isomorphic,

          How can i access httpRequest object at server side? Can you please share one sample?

          I need to clear the cookies and redirect to other URL when i click on logout label.... I am lost in my flow.

          i called a DMI onclick of that label. But i am facing issues in how to achieve my tasks..

          Comment


            #6
            See the DMI overview - you can receive the HttpServletRequest object by just declaring it as a parameter of your DMI method.

            Comment


              #7
              Hi yathish,

              I just did that. Here is my code:

              server/ServletLogout.java
              Code:
              import java.io.IOException;
              import javax.servlet.ServletException;
              import javax.servlet.http.HttpServlet;
              import javax.servlet.http.HttpServletRequest;
              import javax.servlet.http.HttpServletResponse;
              
              @SuppressWarnings("serial")
              public class ServletLogout extends HttpServlet {
              
              	@Override
              	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              		request.getSession().invalidate();
              	}
              
              	@Override
              	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              		doPost(request, response);
              	}
              }
              onClick:
              Code:
              RPCRequest reauthenticateUserRequest = new RPCRequest();
              reauthenticateUserRequest.setActionURL("ServletLogout");
              RPCManager.sendRequest(reauthenticateUserRequest, new RPCCallback() {
              	public void execute(RPCResponse response, Object rawData, RPCRequest request) {
              		Window.Location.reload();
              	}
              });
              web.xml
              Code:
              	<servlet>
              		<servlet-name>ServletLogout</servlet-name>
              		<servlet-class>com.acme.myproject.server.ServletLogout</servlet-class>
              	</servlet>
              	<servlet-mapping>
              		<servlet-name>ServletLogout</servlet-name>
              		<url-pattern>/ServletLogout</url-pattern>
              	</servlet-mapping>
              Best regards,
              Blama

              Comment


                #8
                I have used the same approach. Thanks for posting in detail which can be used by others too..

                Comment

                Working...
                X