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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:17:23+00:00 2026-06-15T08:17:23+00:00

my servlet performs three tasks: When it receives a message resourceupdate stores the requested

  • 0

my servlet performs three tasks:

When it receives a message “resourceupdate” stores the requested resource (an HTML page) to an object sharedClient.

When it receives an asynchronous get (querystring indicated by “t = UPDATE”) adds the object sharedClient this request pending.

When it receives a delivery_resource (indicated by pathinfo myServlet/sharedsessionID – eg. myServlet/8439jfndofsd93jcanjc) performs the dispatch of the resource.

this is my Web.xml:

<servlet>
    <description></description>
    <display-name>MyServlet</display-name>
    <servlet-name>MyServlet</servlet-name>
    <servlet-class>it.package.MyServlet.MyServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>MyServlet</servlet-name>
    <url-pattern>/MyServlet/*</url-pattern>
</servlet-mapping>

I keep all the active SharedClients in this way:

ConcurrentHashMap<String, SharedClient> hmClients = (ConcurrentHashMap<String, SharedClient>)    this.getServletConfig().getServletContext().getAttribute("sharedClients");

And I get the SharedClient with a specific SharedSessionID in this way:

SharedClient targetClient = hmClients.get(ssid);

now the problem:
until I do a resourceupdate servlet works fine, but when i do a delivery_resource (to a path of type myServlet/sharedsessionID) the servlet is unable to obtain the sharedClient reference, and I get a Null Pointer Exception.

if (resourceUri!=null) {
String ssid = resourceUri.substring(1);
ConcurrentHashMap<String, SharedClient> hmClients = (ConcurrentHashMap<String, SharedClient>) this.getServletConfig().getServletContext().getAttribute("sharedClients");
if (hmClients.containsKey(ssid)) {
    SharedClient targetClient = hmClients.get(ssid);
    if (targetClient.getParticipantSession().containsKey(session)) { 
    IoUtils.copy(targetClient.streamSnapshot(), response.getOutputStream());
        }
} else System.out.println("hmClient do not contains ssid"); //always in this branch

From this time also the long polling with asynchronous get are not completed successfully.

If i do not do a delivery_resource to a path of type myServlet/sharedsessionID after the update the asynchronous get continue to function properly.

Thanks to all.

  • 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-06-15T08:17:24+00:00Added an answer on June 15, 2026 at 8:17 am

    ok, i resolved.

    i need to write

     @WebServlet(urlPatterns = {"/myServlet/*"}, asyncSupported=true)
    

    before myServlet declaration.

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

Sidebar

Related Questions

I've a normal Java class (neither a JSP nor a Servlet) that performs some
My Servlet response type is html and my response contains a hyperlink to another
I have a Java servlet that receives data from an upstream system via a
We have a servlet that accepts requests and performs certain actions on external systems.
I want a Servlet to perform always the same tasks. Regardless of if it
I have a servlet which performs various business logic. I want to avoid synchronisation
In my servlet, when a request comes in, I create a date object. Date
Suppose I have a servlet that on doPost method performs some actions. Also I
Using servlet 2.3 is there a way to log a user out when he
My servlet-based web-app sometimes fails to close Log4j log files when redeployed, leaking to

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.