Saturday, 19 August 2017

How to use JSP expression tag in java

How to use JSP expression tag in java

Syntax of JSP expression tag
<%= statement %>

Example of JSP expression tag
In this example of jsp expression tag, we are simply displaying a welcome message.

<html>
<body>
<%= "welcome to jsp" %>
</body>
</html>

Example of JSP expression tag that prints current time

index.jsp
<html>
<body>
Current Time: <%= java.util.Calendar.getInstance().getTime() %>
</body>
</html>

Example of JSP expression tag that prints the user name

File: index.jsp
<html>
<body>
<form action="welcome.jsp">
<input type="text" name="uname"><br/>
<input type="submit" value="go">
</form>
</body>
</html>

File: welcome.jsp

<html>
<body>
<%= "Welcome "+request.getParameter("uname") %>
</body>
</html>

Post a Comment

Whatsapp Button works on Mobile Device only

Start typing and press Enter to search