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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:40:11+00:00 2026-05-13T20:40:11+00:00

We have some code on production which is effectively doing what this code does:

  • 0

We have some code on production which is effectively doing what this code does:

http://java.sun.com/products/java-media/2D/reference/faqs/index.html#Q_Can_I_use_Java2D_to_generate_d

This works fine, however I have noticed some concerning behaviour.

When a servlet is requested and some image data is returned to the browser via a ServletOutputStream, if another request is triggered before the image has finished painting itself on the screen, this will invariably crash the entire Jaguar server with the following trace:

j  com.sybase.jaguar.servlet.JaguarConnection.writeClient([BII)V+0
j  com.sybase.jaguar.servlet.JagHttp11OutputStream.writeChunk()V+92
j  com.sybase.jaguar.servlet.JagHttp11OutputStream.writeOut()V+57
j  com.sybase.jaguar.servlet.ResponseImpl.flushBuffer(Z)V+93
j  com.sybase.jaguar.servlet.ResponseImpl.flushBuffer()V+17
j  com.sybase.jaguar.servlet.JaguarOutputStream.flush()V+19
j  javax.imageio.stream.FileCacheImageOutputStream.close()V+50
j  javax.imageio.stream.ImageInputStreamImpl.finalize()V+8

I have found a couple of references online saying that what I am trying to do is unreliable, ie:

http://forums.sun.com/thread.jspa?trange=15&threadID=560000&forumID=20&tstart=0

However, to be honest, I am unclear as to what the EDT is.

Has anyone come across this issue, and been able to create a workaround for it?

  • 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-13T20:40:12+00:00Added an answer on May 13, 2026 at 8:40 pm

    This sounds like that some request scoped variables are been declared as an instance variable of the servlet. In other words, the code is not threadsafe. There’s only one instance of the servlet in webapplication’s lifetime. It is shared concurrently between all requests. Each request counts as a separate thread. Imagine that you declare variable X (e.g. the image) as instance variable of the servlet and set it in thread A (request A) and then during processing thread B will use the same servlet and override variable X. This will cause trouble in thread A because the variable has been changed during processing it to the output.

    Thus, you should never assign request or session scoped variables as instance variable of the servlet:

    public class ImageServlet extends HttpServlet {
    
        private Image image;
    
        protected void doGet(HttpServletRequest request, HttpServletResponse response) {
            this.image = imageDAO.find(request.getPathInfo()); // Not threadsafe!! image is been shared among all requests.
            // ...
        }
    }
    

    but rather so

    public class ImageServlet extends HttpServlet {
    
        protected void doGet(HttpServletRequest request, HttpServletResponse response) {
            Image image = imageDAO.find(request.getPathInfo()); // Threadsafe.
            // ...
        }
    }
    

    this way each thread has its own variable.

    That said, the EDT is the “Event Dispatcher Thread”. I don’t do Swing so I can’t tell much about it, but it makes sense that he is trying to tell that you should keep all variables threadlocal (i.e. declare them all inside the servlet’s method block) to avoid them being shared among all threads (requests).

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

Sidebar

Ask A Question

Stats

  • Questions 313k
  • Answers 313k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer //Use the fad in out callback $("#toolbar").hover(function () { $(".image").fadeOut("slow",… May 13, 2026 at 10:45 pm
  • Editorial Team
    Editorial Team added an answer Since you want internal scrolling on the bottom div, I'm… May 13, 2026 at 10:45 pm
  • Editorial Team
    Editorial Team added an answer If this js code is on a .js file, then… May 13, 2026 at 10:45 pm

Related Questions

We have some applications that sometimes get into a bad state, but only in
As discussed in similar questions here and here I want to protect my code
I'm working on repairing the test suite for a project of ours, which is
My client has recently taken ownership of an existing web site, with final deliverable
We have a long standing bug in our production code. This is essentially a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.