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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:44:02+00:00 2026-05-25T21:44:02+00:00

Once the submit button is clicked, The name typed on the name textbox is

  • 0

Once the submit button is clicked, The name typed on the name textbox is printed in the servlet . But the response send by the servlet is not coming back to the client. I am not sure where i am going wrong. Need help.

JQuery-Ajax i am calling my sampleServlet.

HTML PAGE

<script>
$(document).ready(function(){
 $(".Submit").click(function(){
 nameVal=$("#name").val();
 alert(nameVal  ) ;
 $.get("http://localhost:8080/dummyService/SampleServlet", {name:nameVal}, function(data) {//This function is supposed to be called once the servlet send the response
 alert(data) ;
 $("#flag").html(data) ;
  });
 });
 });

</script>



<form id="sampleform" method="POST">
<center>
 Enter your Name:  <input id="name" class="name" type="text">  <br/><br/>
                   <input class="Submit" name="Submit" type="button" value="Submit" id="Submit"> 
</center>
</form>
<div id="flag"> </div>

**SampleServlet**

protected void doGet(HttpServletRequest request,
                HttpServletResponse response) throws ServletException, IOException {
  System.out.println("INSIDE DO GET");
  String name = request.getParameter("name");
  System.out.println(name);
  response.setContentType("text/plain");
  PrintWriter out = response.getWriter();
  out.println("Hello " + name);
  out.flush();
  out.close();
 }
  • 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-25T21:44:03+00:00Added an answer on May 25, 2026 at 9:44 pm

    The HTML page containing the JavaScript and your servlet must be on the same hostname and port because of the same origin policy.

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

Sidebar

Related Questions

I've a asp:TextBox and a submit button on my asp.net page. Once the button
In this code i am disabling the submit button when i clicked once and
The following code is being used to disable a Submit button once it has
This is my code for my submit button. Once data submitted to mysql i
For some reason Im unable to get the submit button below to re-enable once
I have simple registration form. Once all information entered, user click submit button and
We all know the good old disable the submit button trick but what are
I have a $.change() event, but when a submit button is pressed, the change
Right now I have a script that will update once the submit button is
There is a html form I have which submits to a Servlet once Submit

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.