Error picking GET attribute in jsp!

Asked

Viewed 148 times

1

I am facing the following problem, I am making the following redirection:

response.sendRedirect("../../index.jsp?NA=1");

Where the url goes like this:

http://localhost:9095/Controle_de_Materiais/index.jsp?NA=1

But when I try to get the attribute, it only gives null:

 <%

        Object obj = request.getAttribute("NA");

        System.out.println("Atributo == " + obj);

        if( obj != null){

             if(Integer.parseInt(obj.toString()) == 1){

               out.println("<p style='float: right;' class='text-danger'><i class='glyphicon glyphicon-asterisk'></i> Credênciais Inválidas!");

                }

        }
  %>

Exit: Saída do console ao executar

Could someone please help me? Thanks in advance!

  • Can post the form code please?

  • I am not using form, I am creating the variable directly in the url! I’m a beginner in jsp, I did it in PHP without problems, I don’t know if you have any problem in jsp.

  • 1

    Have you tried instead of Object obj = request.getAttribute("NA"); use Object obj = request.getParameter("NA");

  • @Laérciolopes Your suggestion came true, thank you very much!

1 answer

1


You must use it:

Object obj = request.getParameter("NA");

Instead of:

Object obj = request.getAttribute("NA");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.