-1

I am working on jee project, When I am clicking the submit button, the function of the button is right but the page is refreshing so the data that i entered on text field for example will be deleted!!!

the code of my jsp is:

<div class="col-sm-4">
    <input type="submit" name="random_generator" width="200" class="btn btn-primary btn-sm" value="Random Task Generator">
 </div>

the code on servlet.java:

if (request.getParameter("random_generator") != null) {
        al.clear();
        control.clear();

        i = Integer.parseInt(request.getParameter("number"));
        u = Double.parseDouble(request.getParameter("max"));

        b = ta.Random_Tasks_Generator(i, u);
        String z = "you have " + i + " tasks," + "\n" + " you must choose a single task to complete the work";
        request.setAttribute("btn", z);

    }

What should I do to prevent the page refresh?

sebenalern
  • 2,515
  • 3
  • 26
  • 36
Jamél Samar
  • 3
  • 1
  • 3

1 Answers1

0

this is what i get while executing my code. i must enter the numbre of tasks a the maximum of utilization factor then i click on random tasks generator to get the list of tasks. when i click on the button, the page refresh and the data (nb tasks and utilization factor) are deleted and i need to them later !!

Jamél Samar
  • 3
  • 1
  • 3