Skip to content
Advertisement

How do I check if variable exists in a jsp page for post in index?

well this is what I want to do. I have a website that is supposed to show post created from an Admin dashboard in index page using jsp as language, I did this in Php but I can’t find how to do it in jsp in this case, how can I check if the variable “pageno” exists to begin with?

in php is like:

if(isset($_GET['pageno'])){
$pageno = $_GET['pageno'];
}else{$pageno = 1;
}

how can I do this in jsp?

I’ve been trying to search but no luck.

Thanks a bunch in advance!

Advertisement

Answer

i think you are asking about jsp java blow code will help you to check the value of variable in jsp java.

<%
boolean exist = false;
        int pageno =request.getParameter("pageno");
        if(pageno !=null){
            exist  = true;
            out.println(pageno);
        }else{
            exist = false;
            out.println("page num donot exist");
        }
    %>
Advertisement