Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--Shavit Borisov-->
- <!--15.1.15-->
- <!--http://pastebin.com/GXVCpgu4-->
- <%@ page language="java" contentType="text/html; charset=utf-8"
- pageEncoding="utf-8"%>
- <%@ page import="java.util.Random"%>
- <%!
- boolean isPrime(int x) {
- int i = 2;
- if(x <= 0)
- return false;
- if(x <= 2)
- return true;
- while((x % i) != 0)
- i++;
- return (i == x);
- }
- int factorial(int x) {
- int result = 1;
- for(int i = 1; i <= x; i++)
- result *= i;
- return result;
- }
- %>
- <%
- Random rnd = new Random();
- int x = rnd.nextInt(100);
- int y = rnd.nextInt(12) + 1;
- %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
- <title>First JSP</title>
- </head>
- <body>
- <h1>My first JSP file</h1>
- Your host name/ip: <%=request.getRemoteHost()%><br>
- Current time on the server: <%=new java.util.Date()%><br>
- The number drawn is: <%=x%> and it is <%=isPrime(x) ? "a" : "not a"%> prime number.<br>
- The factorial of <%=y%> is <%=factorial(y)%>.<br>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement