Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What are different types of scripting elements in jsp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 458
    Comment on it

    JSP supports various programming language codes. With the help of scripting elements, you can write java code inside the jsp page.

    There are three types of scripting elements which are really useful for inserting java code.

    1. scriplet tag

    With the help of this tag, java source could can be executed inside the jsp page.

    syntax: <% [source code] %>

    Example:

    <html>  
    <body>  
    <% out.print("Hello"); %>  
    </body>  
    </html>  
    

    This is print hello in your browser.

    2.Expression tag

    This is used to display the values written inside the tag. No need to use out.println in this. eg. you can display values inside a variable. etc.

    syntax: <%= [value]%>

    Example:

    <html>  
    <body>  
    <%= "Welcome" %>  
    </body>  
    </html>  
    

    This will print Welcome on your browser.

    3.Declaration tag

    Any method or variables which needs declaration are declared inside this tag.

    syntax: <%!declarations %>

    Example:

    <html>  
    <body>  
    <%! int value=10; %>  
    <%= "The value declared is "+value %>  
    </body>  
    </html>  
    

    This will assign the variable 'value' with the value as '10' and it is then printed on your browser.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: