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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:37:26+00:00 2026-05-30T22:37:26+00:00

I am using a servlet as my server to send updates to my jsp

  • 0

I am using a servlet as my server to send updates to my jsp client(Using HTML5 SSE). This is my jsp code

<script type="text/javascript">

    if(typeof(EventSource)!=="undefined")
      {
      var source=new EventSource("/server");
      source.onmessage=function(event)
        {
        document.getElementById("news1").innerHTML+=event.data + "<br />";
        };
      }
    else
      {
      document.getElementById("news1").innerHTML="Sorry, your browser does not support server-sent events...";
      }
      </script>

This is my servlet code

public void doPost(HttpServletRequest request, HttpServletResponse response) {

    try{
    System.out.println("Begin for session: " + request.getSession(true).getId() + " " + response.getWriter());  
response.setHeader("pragma", "no-cache,no-store");  
response.setHeader("cache-control", "no-cache,no-store,max-age=0,max-stale=0");  

response.setContentType("text/event-stream");  

PrintWriter out = response.getWriter();  

int messagesSent = 0;  
while (true) {  
    out.print("data: {" + messagesSent++ + "}\n\n");  
    out.flush();  
     }} catch(Exception e){System.out.println(e);}

There is no response from server. I have deployed my servlet in jboss and the servlet is not at all being called by jsp file. The print statement at the beginning of servlet is not executing.

  • 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-30T22:37:27+00:00Added an answer on May 30, 2026 at 10:37 pm

    Are you able to access the Servlet directly i.e. not from the javascript script?

    You need to double check first that this Servlet is accessible regardless of the call from javascript.

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

Sidebar

Related Questions

How can I upload files to server using JSP/Servlet? I tried this: <form action="upload"
I send data from a browser to a servlet using JavaScript, then the server
I am using below code to send data to servlet HttpConnection c = (HttpConnection)Connector.open(http://localhost:8585/resposweb/resposweb?action=create_order;deviceside=true);
I have this servlet which needs to send mail using Java Mail API, however
I am using URLConnection Object to send data from my android client to server.
I am using servlet there is two method redirect and forward both are send
i am trying to upload an image from a jsp page using servlet. but
I am developing a chat website using jsp/servlet.I will be hosting my website on
I am able to send data to the server using JSON and get back
i want to send json to server using Spring 3.x, i use annotation @RequestBody,

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.