JSP Expression Tag, How to Print Value of any Variable without out.write() in JSP, How to call a method in JSP


JSP Expression Tag, How to Print Value of any Variable without out.write() in JSP, How to call a method in JSP

If you want to print the value of any variable in JSP so you can simply use the out.write(variablename) inside the scriptlet tag but, if you dont want to use scriptlet and don't want to use the out.write() method then, the JSP also provide a special tag for doing this task, you can print the value of any variable without using out.write() method, this tag called the Expression Tag, with the help of this tag you can easily call a method too.

Syntax of Expression Tag

<%= expression %>

Example of Expression Tag

<html>
<head>
<title>Handling Request</title>
</head>
<body>

<%! String username="";%><%
String user=request.getParameter("user");

String pass=request.getParameter("pass");
if(user.equlas("admin")&&pass.equals("admin"))
{
username=user;
}%>
<h1>Welcome <%= username %></h1></body>
</html>


Thanks for visiting

{ 0 comments... read them below or add one }

Post a Comment