Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1085295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:40:17+00:00 2026-05-16T22:40:17+00:00

I am using GWT and RPC in my app. after session expires when I

  • 0

I am using GWT and RPC in my app. after session expires when I do a RPC call, because of my login-filter the request redirect to login.jsp, but my problem is client doen’t show me login.jsp instead the RPC’s onFailure raised.

It means I should handle all my rpc’s onFailure events for redirecting to login page ?!!!!

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:40:18+00:00Added an answer on May 16, 2026 at 10:40 pm

    I agree with pathed that you should do redirecting in your AsyncCallbacks. However, you don’t need to explicitly use your custom MyAsyncCallback callbacks instead of standard GWT AsyncCallback. This is important for example when you already have a lot of code that uses standard callbacks.

    When you invoke GWT.create(MyService.class) GWT generates proxy for your MyServiceAsync service interface. This proxy is responsible for communicating with the server and invoking your callbacks when it gets data from the server. Proxies are generated using GWT code generators mechanism and by default GWT uses ServiceInterfaceProxyGenerator class to generate these proxies.

    You can extend this default generator (ServiceInterfaceProxyGenerator class) to automatically use your custom MyAsyncCallbacks in all callbacks invocations. We recently did exactly that in a project. Below there is source code which we used.

    Code for MyAsyncCallback, it is identical to the one presented by pathed:

    package my.package.client;
    
    import com.google.gwt.user.client.rpc.AsyncCallback;
    
    public class MyAsyncCallback<T> implements AsyncCallback<T> {
    
        private final AsyncCallback<T> asyncCallback;
    
        public MyAsyncCallback(AsyncCallback<T> asyncCallback) {
            this.asyncCallback = asyncCallback;
        }
    
        @Override
        public void onFailure(Throwable caught) {
            if (caught instanceof SessionTimeoutException) {
                // redirect
                return;
            }
    
            asyncCallback.onFailure(caught);
        }
    
        @Override
        public void onSuccess(T result) {
            asyncCallback.onSuccess(result);
        }
    
    }
    

    Code for GWT code generator (MyRpcRemoteProxyGenerator):

    package my.package.server;
    
    import com.google.gwt.core.ext.typeinfo.JClassType;
    import com.google.gwt.user.rebind.rpc.ProxyCreator;
    import com.google.gwt.user.rebind.rpc.ServiceInterfaceProxyGenerator;
    
    public class MyRpcRemoteProxyGenerator extends ServiceInterfaceProxyGenerator {
    
        @Override
        protected ProxyCreator createProxyCreator(JClassType remoteService) {
            return new MyProxyCreator(remoteService);
        }
    }
    

    And generator helper class (MyProxyCreator):

    package my.package.server;
    
    import java.util.Map;
    
    import com.google.gwt.core.ext.typeinfo.JClassType;
    import com.google.gwt.core.ext.typeinfo.JMethod;
    import com.google.gwt.user.rebind.SourceWriter;
    import com.google.gwt.user.rebind.rpc.ProxyCreator;
    import com.google.gwt.user.rebind.rpc.SerializableTypeOracle;
    
    
    public class MyProxyCreator extends ProxyCreator {
    
        private final String methodStrTemplate = "@Override\n"
                + "protected <T> com.google.gwt.http.client.Request doInvoke(ResponseReader responseReader, "
                + "String methodName, int invocationCount, String requestData, "
                + "com.google.gwt.user.client.rpc.AsyncCallback<T> callback) {\n"
                + "${method-body}" + "}\n";
    
        public MyProxyCreator(JClassType serviceIntf) {
            super(serviceIntf);
        }
    
        @Override
        protected void generateProxyMethods(SourceWriter w,
                SerializableTypeOracle serializableTypeOracle,
                Map<JMethod, JMethod> syncMethToAsyncMethMap) {
            // generate standard proxy methods
            super.generateProxyMethods(w, serializableTypeOracle,
                    syncMethToAsyncMethMap);
    
            // generate additional method
            overrideDoInvokeMethod(w);
        }
    
        private void overrideDoInvokeMethod(SourceWriter w) {
            StringBuilder methodBody = new StringBuilder();
            methodBody
                    .append("final com.google.gwt.user.client.rpc.AsyncCallback newAsyncCallback = new my.package.client.MyAsyncCallback(callback);\n");
            methodBody
                    .append("return super.doInvoke(responseReader, methodName, invocationCount, requestData, newAsyncCallback);\n");
    
            String methodStr = methodStrTemplate.replace("${method-body}",
                    methodBody);
            w.print(methodStr);
        }
    
    }
    

    Finally you need to register the new code generator to be used for generating proxies for async services. This is done by adding this to your GWT configuration file (gwt.xml file):

    <generate-with
        class="my.package.server.MyRpcRemoteProxyGenerator">
        <when-type-assignable class="com.google.gwt.user.client.rpc.RemoteService" />
    </generate-with>
    

    At the beginning it may seem to be a very complicated solution 🙂 but it has its strengths:

    • You can still use standard GWT AsyncCallbacks
    • You can enforce redirecting when session times out globally for your application
    • You can easily tun it on and off (by adding or removing generate-with in your GWT config files)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a login page in GWT using widgets and RPC. After succesful login,
We're currently using GWT RPC for serialization on a GWT project but we're currently
I am developing a simple app using GWT, Hibernate, RPC in eclipse. I am
I have a GWT 2.3 web app using Objectdb via Rpc. In the embedded
I am using GWT-RPC to call an ANTLR grammar. If the grammar fails, I
I created a Windows desktop gadget using GWT RPC but how could I make
I'm using GWT RPC to send a string containing a date from the client
When using GWT I get following warning: Referencing deprecated class 'com.google.gwt.user.client.rpc.SerializableException' While it's only
I am using GWT to write a simple app. Ive divided the view into
I am evaluating if there is a performance variation between calls made using GWT-RPC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.