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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:25:35+00:00 2026-06-08T21:25:35+00:00

I have a servlet program for counting numbers, I want to control it through

  • 0

I have a servlet program for counting numbers, I want to control it through an html interface.
by pressing the start button the program must start running and by pressing pause button the servlet program must be paused and by clicking on the restart button it must restart again. by the way i used thread. My problem is that each time I should click one button and send its value to the servlet, and when I’m getting the buttons values inside the servlet a NullPointerException is occur… any help ??

  • 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-08T21:25:36+00:00Added an answer on June 8, 2026 at 9:25 pm

    I wouldn’t use a Thread for that purpose and in general is not usually a good idea to create threads in servlets.

    Say we count one number per millisecond meaning: it will give me the time between one click and another in milliseconds.

    One work around could be:
    Click on start = save the start time in the session.
    click on stop = to get the count we do currentTime-StartTime (saved in session)

    Now if you really must use Threads be sure then to create it using another class.
    One suggestion might be create a ThreadManager class and store it in the session (use a listener for this) and then start it in that session object.
    Even better store the ThreadManager inside the servletContext and have a way to create your thread per session.
    To create Threads favor the Executor classes instead of the Thread classes.
    Also make sure you stop your threads since having threads created by us inside a web container may prevent it from stoping entirely.

    If you provide some code I can help you further.
    Good luck, have fun.

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

Sidebar

Related Questions

I have this servlet program and an external .jar file (written by someone else)
I have a servlet running on GAE and I have a cron job that
I have a Servlet called Menu that generates some html and a dynamic menu,
I have connected Java program to Oracle database using JDBC. I want to store
I have written sample program which uses XSLT to generate HTML response. Check below
I have developed the following program/architecture: A) A Java servlet receives POST requests, gets
I have a problem with my program. I have a servlet; in this servlet
Unix gurus! I have a Java program which passes some parameters to a Servlet
I have the following exception at the time of running JSF program. org.apache.jasper.JasperException: An
I have a servlet program. This is my code: public class CompanionProxy extends HttpServlet

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.