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

Time:09-28

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!

CodePudding user response:

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");
        }
    %>
  • Related