Below is my first.jsp
from which I am supposed to call second.jsp
page using AJAX... And I need to pass a value from first.jsp
page to second.jsp
page.
And then in the second.jsp
page use that variable value and make a SELECT query using that and return the data back to first.jsp page
Below is my first.jsp page
<html>
<head>
</head>
<body>
<p><input type="radio" name="dish" value="Indian" id="radioButton"> Continental</input></p>
<p><label for="male" id="columnData">Male</label></p>
<script>
$(document).ready(function() {
$('#radioButton').click(function() {
alert($('#columnData').html());
var name = $('#columnData').html();
$.ajax({
type:"POST",
url: "second.jsp",
data:"name=" +name,
success: function(success) {
}
});
});
});
</script>
</body>
</html>
Below is my second.jsp page
in which I need to retrieve the value from first.jsp
and make a select query and return the result back..
<html>
<head>
<title>SELECT Operation</title>
</head>
<body>
<sql:setDataSource var="snapshot" driver="org.postgresql.Driver"
url="jdbc:postgresql://localhost/postDB"
user="postgres" password="hello"/>
<sql:query dataSource="${snapshot}" var="result">
// use the name variable value here passed from first.jsp page?
SELECT * from Employees where name = ?;
</sql:query>
</body>
</html>
I am not sure how to pass the value from one JSP page to another JSP page and then return back the result from second.jsp page to first.jsp page?