# Calculating square root using JSP & jQuery

In this tutorial, we will find square root of any number with the help of JSP & jQuery.

## Calculating square root using JSP & jQuery

In this tutorial, we will find square root of any number with the help of JSP & jQuery. In this example, we have a JSP file which have jQuery 'javascript' :

In this video tutorail I am going to explains you to calculate the square root using jQuery. Sever side program will be called from a jsp page using jQuery and then server side program will return the calcuated value. The value returned from server will be displayed on the screen.

index.jsp

 ```   Simple jQuery and JSP example         Enter number:

```

Here is the video of “Calculating square root using JSP & jQuery?”:

script.js

 ``` \$(document).ready(function() {   \$('#form').submit(function(){   var number = \$('#number').val();    \$.ajax({type:"post",url:"calculate.jsp",data:"number="    +number,success:function(msg){\$('#result').hide();    \$("#result").html("

" + msg + "

").fadeIn("slow"); } });   return false; }); });```

calculate.jsp

 ``` <%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%> <% int number = 0; if(request.getParameter("number")==null){   out.println("Enter a number!"); } else {      number = Integer.parseInt(request.getParameter("number"));   out.println("Square root of "+ number + " is "    + Math.sqrt(number)); }/font> %%>```

OUTPUT :