❮ Previous Next ❯

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
❮ Previous Next ❯

Follow Us




  Tutorials

Popular Links

Contact Us

address Plot No-N6/530,2ND Floor
Nayapalli,Jayadev Vihar
      Bhubaneswar-751015
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved