Wednesday 21 February 2018

JSP Scriptlet tag

JSP Scriptlet tag,syntax of JSP Scriptlet tag,Example of JSP scriptlet tag that prints the user name,Example of JSP scriptlet tag

In JSP, java code can be written inside the jsp page using the scriptlet tag. Let's see what are the scripting elements first.

JSP Scripting elements

The scripting elements provides the ability to insert java code inside the jsp. There are three types of scripting elements:

  1.      scriptlet tag
  1.     expression tag
  1.      declaration tag

JSP scriptlet tag

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

Syntax:

       <%  java source code %>  

Example of JSP scriptlet tag

In this example, we are displaying a welcome message.
         <html>  
         <body>  
          <% out.print("welcome to jsp"); %>  
          </body>  
          </html>  

Example of JSP scriptlet tag 

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="go"><br/>  
      </form>  
      </body>  
      </html>  

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






DashZin

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

1 comments:

  1. Big data service providers should understand the need of Data, and they should work to build more appropriate services to meet the requirements of their clients.

    ReplyDelete