source file name: Primeno.html
<html>
<head>
<title>Prime no JSP program</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<form action="http://localhost:8080/JspPrograms/PrimeNumber.jsp" method="post">
enter any no:
<input type="text" name="t1" >
<br>
<input type="submit" >
</form>
</body>
</html>
source file name: PrimeNumber.jsp
int n=Integer.parseInt(request.getParameter("t1"));
out.println(" given number is: "+n);
int d=2;
while(d<n)
{
if(n%d==0)
{
out.println("<br> "+n+" is not Prime no.");
break;
}
else
d++;
}
if(n==d)
out.println("<br>"+n+" is Prime no.");
%>
output:
0 Comments
Post a Comment