I tried to make an Algorithm who show Pascal's triangle with degree 5
this is the code :
<%@page import="java.util.Scanner"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%!int i;
int j;
int n=5;
int [] [] triangle;
%>
<%
System.out.println("Les nombres n :");
triangle=new int[n][n];
triangle[0][0]=1;
for(i = 1; i < n ; i++ )
{
triangle[i][0] = 1;
for(j = 1; j < i ; j++ )
{
triangle[i][j] = triangle[i-1][j-1]+triangle[i-1][j];
}
triangle[i][j] = 1;
}
for(i=0;i<n;i++)
{
for(j = 0; j<n ;j++)
{
if(triangle[i][j]!=0)
System.out.print(triangle[i][j] +" ");
}
System.out.println();
}
%>
</body>
</html>
When i run the jsp file , nothing is happening (blank page)
Do you know what the problem please ? and how to fix it ?
System.out.println()
prints to the console, not the network. You'll need to use out.println()
instead, where out
is a javax.servlet.jsp.JspWriter
and is provided in the JSP.