Create push button

1

I have a problem that I did not find any solution to, I'm trying to create a forward button to move the pages of my .pdf file 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 open and "i" is the page number that will open the page. In the beginning the value of "i" is 1, but if the user clicks on forward it is directed to another JSP page where I change the value of "i" and then return to the JSP for viewing the pdf. In 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 forward button, the error org.apache.jasper.JasperException: java.lang.NullPointerException

I have already debugged the code and the error occurs when I try to fetch the JSP page, but I do not know why.

    
asked by anonymous 23.09.2016 / 14:23

1 answer

2

I was able to figure out the error, I needed to pass the file name to the JSP page.

    
23.09.2016 / 14:28