0

I have some jsp files where they communicate with each other through servlets. I take some user requests from page1.jsp and then through servlet I go to page2.jsp file where I post some Mysql database results.

The user is checking or unchecking some checkboxes, and waits to see other results from the Mysql Database in the same page2.jsp, without going to the servlet.

I don't know how to refresh the page and show other results. I use jquery to catch the checkbox option value. And keep it in a hidden input. I want that variable value in java to search my database with other query. When I use <% String str = request.getParameter("namevalue")%> my string result is null, because I am not sending it to the servlet.

What are my options in this case?:(

user3612192
  • 61
  • 2
  • 4
  • `(function($){ $('#checkClass').click(function() { myInput = $('#checkClassInput').val('')[0]; $('.a-checkbox:checked').each(function(){ myInput.value += this.value + ','; });` the input shows me the results of what I am clicking from the checkboxes but i can't assign the value direct to a java variable – user3612192 May 23 '14 at 07:51
  • It might help you [Jquery assign value to JSP variable](http://stackoverflow.com/questions/15893946/jquery-assign-value-to-jsp-variable) – Braj May 23 '14 at 07:55
  • Simply update the section of the JSP page where you want to use that variable using JQuery. – Braj May 23 '14 at 08:01

1 Answers1

0

First you missed semicolon in the end of the statement in Scriptlet <% %>.

The user is checking or unchecking some checkboxes, and waits to see other results from the Mysql Database in the same page2.jsp, without going to the servlet. I don't know how to refresh the page and show other results.

page1.jsp -> servlet -> page2.jsp

Now you want some values to be updated without hitting the servlet and page refresh then try with AJAX

Have a look this post How to show value from database to jsp without refreshing the page using ajax

Have a look at AJAX example with Database

Community
  • 1
  • 1
Braj
  • 46,415
  • 5
  • 60
  • 76