JSP scriptlet tag

A scriptlet tag is used to execute java source code in JSP.

The general form is:

<% java source code %>

Example;

<html>
<body>
<% out.print("welcome to java8s.com"); %>
</body>
</html>

Let’s see another example of JSP scriptlet tag that displays the user name. In this example, we have created two files index.html and welcome.jsp. The index.html file gets the username from the user and the welcome.jsp file prints the username with the welcome message.

index.html

<html>
<body>
<form action="welcome.jsp">
<input type="text" name="uname">
<input type="submit" value="ok">
</form>
</body>
</html>

welcome.jsp

<html>
<body>
<form>
<%
String str=request.getParameter("uname");
out.print("welcome "+str);
%>
</form>
</body>
</html>

Output

user
welcome

Our Services:

Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Projects

SILAN Technology
Call to: 9439202111  |  9658317757  |  0674-2361252

Comment