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 7689777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:14:36+00:00 2026-05-31T20:14:36+00:00

This issues comes up when executing a particular workflow – User is logged in

  • 0

This issues comes up when executing a particular workflow –

  1. User is logged in
  2. Session expires
  3. User tries to do something on the currently page which triggers an AJAX request
  4. Since session is expired the ajax request fails
  5. I need to display a message to this effect.

Now the problem appears. I have an interceptor which properly catches that the session expires. It also properly identifies that the original request was AJAX. So this means the interceptor needs to respond with a json response (accepted input format to any of my ajax calls).

Interceptor Code –

public class AuthenticationInterceptor implements Interceptor {

    private InputStream jsonStream;

    @Override
    public String intercept(ActionInvocation actionInvocation) throws Exception {
    ... // boilerplate init code.
    if (memberId == null 
        && StringUtils.equals("XMLHttpRequest", request.getHeader("X-Requested-With"))) {

        Map<String, Object> responseObject = Maps.newHashMap();
        Set<String> errors = Sets.newHashSet();
        errors.add("Your session has expired. Please refresh page and login.");

        responseObject.put("errors", errors);
        responseObject.put("success", false);

        jsonStream = ResponseUtils.getJSONResponseStream(responseObject);

        return "json";
    }
}


public InputStream getJsonStream() {
    return jsonStream;
}

public void setJsonStream(InputStream jsonStream) {
    this.jsonStream = jsonStream;
}

struts.xml code –

<package name="raisin" namespace="/raisin" extends="secure">
    <interceptors>
        <interceptor name="authentication" class="interceptors.AuthenticationInterceptor"/>
    </interceptors>
    <global-results>
      <result name="json" type="stream">
        <param name="contentType">application/json</param>
        <param name="inputName">jsonStream</param>
        <param name="bufferSize">1024</param>
      </result> 
    </global-results>  
    ...
  </package>

So when this workflow is executed I get the below exception –

java.lang.IllegalArgumentException: Can not find a java.io.InputStream with the name [jsonStream] in the invocation stack. Check the &lt;param name=&quot;inputName&quot;&gt; tag specified for this action.
    org.apache.struts2.dispatcher.StreamResult.doExecute(StreamResult.java:237)
    org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
    com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:498)

I do not understand how is this possible since I create public get/set methods inthe interceptor for jsonStream. Also I put a sysout in getJsonStream method. It turns out it is never called.

Any pointers appreciated.

  • 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-31T20:14:37+00:00Added an answer on May 31, 2026 at 8:14 pm

    i believe you approach is wrong here and you are not using Interceptors the way they should be used.
    Interceptors instances are shared among the Actions.For each request a new instance of action will be created by S2 but the Interceptors will be reused, which means Interceptors are stateless and you are trying to set state of request process in the interceptor.

    My suggestion is Don’t try to store the data related to request processing as its not part of Interceptor role.
    Just check the Ajax request response and try to see what result you are getting back, based on that you can show the error message.

    Update

    One of the possible solution to check session timeout handling.This has been discussed in following thread struts-2-session-timeout

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Still having issues with this problem. Please help if you can. So I am
Im having issues getting this to work, maybe its not even possible? I have
This might be a simple answer, but I am having some issues writing this
This question deals with concurrency issues, for suggestions on how to display a busy
Having issues referencing $(this) from within a the nested ajax 'success' function... I know
This is an exact duplicate of: IE6 issues with transparent PNGs Firefox: IE 6:
This is one of my first issues. Whenever I exit out the program, tcpClient.Connect()
This is something that I was exploring to see if I could take what
Has anyone come across this issue? Seems MS have broken it with their own
I've come across this issue in my application, and have reproduced it using Apple's

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.