Create Next button

Asked

Viewed 73 times

1

I’m having a problem that I haven’t found any solution, I’m trying to create a forward button to pass the pages of my file. pdf that is displayed on my JSP page.

        String arquivo = ""; 
        String i = "";
        try {
            arquivo = request.getParameter("nomeArq");
            if (arquivo.equals("()null") || arquivo.equals("null") || arquivo.equals("")) {
                arquivo = request.getAttribute("nomeArquivo").toString();
            }
        } catch (Exception e) {
            arquivo = request.getAttribute("nomeArquivo").toString();
        }
        try {
            i = request.getParameter("numeroPag").toString();
            if (i.equals("()null") || i.equals("null") || i.equals("")) {
                i = request.getAttribute("pagina").toString();
            }
        } catch (Exception a) {
            i = request.getAttribute("pagina").toString();
        }

Where "file" is the name of the file to be opened and "i" is the number of the page to be opened. At first the value of "i" is 1, but if the user clicks forward it is directed to another JSP page where I exchange the value of "i" and then return to the JSP of the pdf view. On my JSP page to advance the page I did so:

        String p = request.getParameter("NumPag");
        int pagina = Integer.parseInt(p) + 1;
        request.setAttribute("pagina", pagina);
        request.getRequestDispatcher("VisualizarPDF.jsp").forward(request, response);

But every time I click the next button the error occurs org.apache.jasper.JasperException: java.lang.NullPointerException

I already debug the code and the error occurs when I try to get the value of the JSP Advance page, but I don’t know the reason why.

1 answer

2


I was able to find the error, I needed to pass the name of the file to JSP page

Browser other questions tagged

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