Sunday 8 March 2015

jsp Expressions

You can evaluate java expression in jsp using <%= %> tag.

Syntax
<%= expression >

Example
<%= new Random().nextInt() %>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Generate Random Number</title>
    </head>
    <body>
        <h1>Random Number:
            <%= new Random().nextInt() %>
        </h1>
    </body>
</html>

Output





Prevoius                                                 Next                                                 Home

No comments:

Post a Comment