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

  • Home
  • SEARCH
  • 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 362k
  • Answers 362k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Trying to use scanf to read strings with spaces can… May 14, 2026 at 3:08 pm
  • Editorial Team
    Editorial Team added an answer On Sun's Windows JDK, the thread will in fact throw… May 14, 2026 at 3:08 pm
  • Editorial Team
    Editorial Team added an answer Have you looked at the MSDN example? Asynchronous Server Socket… May 14, 2026 at 3:08 pm

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.