JSP information for another JSP

0

Example: I have a JSP A, which has some information and a button. When you press this button, JSP A sends variables to B (like id, name ...). B would use this information and refresh the page without redirecting. Is there any way to do this?

    
asked by anonymous 08.04.2016 / 03:05

2 answers

0
Is everything good? Put a snippet of the code you're trying to make to make it easier to support what you need. Without having this notion it is more complicated to help.

We will have some options depending on what you are using. If it's just jsp with servlet, use vraptor or some other framework. For each situation you may have a different option.

But taking into account only the logic you need, I will consider that you are using a java method that has the following behavior:

public void teuMetodo(ActionRequest actionRequest, ActionResponse actionResponse) {
   //código aqui
   actionResponse.sendRedirect("paginaQueVcQuer.jsp");//Utilize o actionResponse para redirecionar após capturar os dados que precisa no seu form.
}

Hugs!

    
08.04.2016 / 05:06
0

Hello @Thiago R.

There are a few ways to do this. One of them is by form submit.

Another would be to use JSON. You create a Javascript function that will be triggered by clicking this button, then in this function you will pass the parameters you want by JSON indicating the next page. It would look something like this:

function enviarDados() {
    $.ajax({
        url: '/paginaJSP_B',
        type: 'POST',
        contentType: false,
        data: { campo1: "abc", campo2: "XYZ" },
        dataType: 'json'
    });
}
    
01.07.2018 / 01:56