Get all updates of Java4s
Follow Us: Email Newsletter

Submit Form Without Refreshing Page In Java/Jsp With jQuery

jQuery » On Sep 16, 2012 { 15 Comments } By Sivateja

Hi friends, let us see how to submit form with out page refresh in java servlets applications with jQuery api.  i believe you can follow this procedure to implement the same in struts or any MVC applications too.



Files required

  • index.jsp
  • web.xml
  • jquery-1.4.2.min.js [ You can download from ]

Web application Directory Structure:


Note: saveIt is servlet URL pattern.


Note: In line number 25,27 i have written out.print statements as

out.print(“<font color=#’43b200′><b>Data saved successfully….!!</b></font>”);
out.print(“<font color=#’ea0909′><b>Sorry..!! Got an exception.</b></font>”);

Which am not able to show above :-)


Video Output:

You Might Also Like

  ♦ About Author ♦

Full Stack( Java/J2EE & UI/UX ) Developer and founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog. Sign-up for the Email Newsletter for your daily dose of Java tutorials.


15 Responses to “Submit Form Without Refreshing Page In Java/Jsp With jQuery”
  1. Yannikator says:

    Thanks a lot for this one.
    It was usefull to understand how use jQuery in order to use servlet in background process.

    Just one thing, there’s a mistake in the javascript in index.jsp:
    search : $(‘.ibutton’).click(function(e) {
    and replace by : $(‘#ibutton’).click(function(e) {

    And it Work!

  2. Java4s says:


    Thanks bro, its been corrected now ;)

  3. This Website is veryusefull for beginers, thank you vey much

  4. Yes..this website is very good for Beginners..Thanks a lot.. Continue in this way..

  5. Navaneet says:

    Thanks a lot for this example, it’s so useful for first time…

  6. Prakhar says:

    can we do this using ajax, if yes then which one is better and why ?

  7. Smitha51 says:

    Really great info can be found on site.

  8. sunil tariyal says:

    these example is very helpful for us but i need a form submission example using only ajax not using jquery.
    so can u please suggest me example which is helpful for me.

  9. really good site for beginers…expecting more help from this site

  10. prasad says:


    For example if i have 6 fields in my form, then will use
    data :form.serialize() method in ajax to send data.

    Here how do i get data in servlet.

    [I wnat to know how to send form data which contain more than one field and with out query param]….


  11. balaraju says:

    first thanks to you for providing such a good concepts with examples
    i was studied complete AJAX. It is very nice

    please provide jQuery also like AJAX (that is with complete explanations)

  12. sarikapawar says:

    Thanks A lot….this is very helpful for me
    One request please provide jQuery tutorial from basics

  13. yuvaraj says:

    please explain the flow of control in program ..briefly exaplin the javascript fuctions…please..sir

  14. Yogesh says:


    Its nice article.
    Will you explain what is abcd in your web.xml

  15. Dhruv says:

    I’ve put all the files in one folder. it is not working. what to do?


By posting your answer, you agree to our comments policy.
What would you like to learn today?
Browse these popular technologies
Hibernate spring struts Servlets ajax Log4j jQuery Json Core Java Web Services AngularJs
Most Recent Tutorials
Hibernate_Logo Hibernate Recent Posts Spring_Logo Spring Recent Posts Struts_Logo Struts Recent Posts
Useful Links Current & UpComing Tutorials
  Web Services [ SOAP ], JSP
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2016 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.