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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:09:23+00:00 2026-05-12T07:09:23+00:00

I need to know if there are any issues with the below code as

  • 0

I need to know if there are any issues with the below code as far as threading goes. I was always under the impression that so long as class level variables are not used threading is not an issue.

public class UploadReferralImage extends HttpServlet
{
    String CLASS_NAME = "UploadReferralImage";

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
   // Not handling Get, service must be invoked via Post.
}

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
    String METHOD_NAME = "doPost";
    LogHelper.debug(PACKAGE_NAME, CLASS_NAME, METHOD_NAME, "Made it to the servlet");
    String reply = upload(request);
    response.setHeader("Content-Type", "text/xml");
    response.getWriter().write(reply);
    response.getWriter().flush();
    response.getWriter().close();
}

public String upload(HttpServletRequest request)
{

    String METHOD_NAME = "upload";
    LogHelper.debug(PACKAGE_NAME, CLASS_NAME, METHOD_NAME, "Inside upload");
    String replyMsg = "Unable to call ImageUpload";

    try
    {
        ObjectInputStream inputFromApplet = new ObjectInputStream(request.getInputStream());
        FileBean fBean = (FileBean) inputFromApplet.readObject();

        inputFromApplet.close();
        LogHelper.debug(PACKAGE_NAME, CLASS_NAME, METHOD_NAME, fBean.getFileName());

        replyMsg = doImageUpload(fBean);

        } 
        catch (IOException e)
    {   
        e.printStackTrace();
            replyMsg = "Exception :" + e.toString();

    } 
        catch (ClassNotFoundException e)
    {
        e.printStackTrace();
            replyMsg = "Exception :" + e.toString();
    }

    return replyMsg;
}

private String doImageUpload(FileBean fBean)
{
       //Save the file and return the response
       SaveCaseClientAgent saveCaseClientAgent = new SaveCaseClientAgent();
       saveCaseClientAgent.save(fBean);
}
  • 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-12T07:09:23+00:00Added an answer on May 12, 2026 at 7:09 am

    You are correct.

    As long as you stay away from using class-level variables your Servlet will be thread safe.

    To be safe, might as well make your class-level String final:

    final String CLASS_NAME = "UploadReferralImage";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to know how to turn on Code Coverage when running TFS builds
I need to know what is code compiled unit in .net. It s located
I need to know about Epoll On linux System. Could you recommend manual or
I need to know how the performance of different XML tools (parsers, validators, XPath
I need to know how much space occupies all the databases inside an SQL
I need to know when the memory will be allocated for a particular program.
I need to know, from within Powershell, if the current drive is a mapped
I need to know how I get the stream of the headers and footers
I need to know what internet connection is available when my application is running.
I need to know when the user finishes editing a cell in an NSTableView.

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.