Monday, March 15, 2010

Add dynamic content using Expression Tags in JSP


Its same as in fairy tales, once upon a time there where static pages ruling the web. And now, everyone is wishing to have content to be present according to the situation. Everything is live now. Dynamic content is what everyone wishes to see.

JSP pages are one which allow one to embed Java code to HTML. This is where we take advantage in creating dynamic content.

Expression Tag 

You need to embed your Java expressions in between <%= and %>

whatever is given in between, it is evaluated at run time.

Following is an example program…



        <title>JSP 1. Expression Tags</title>



        <div align="center">

        <h3>Current Time:</h3>

        <%= new java.util.Date() %>  <br/>

        <h4>Refresh the page to update the time !!!</h4>





Above code displays current time as and when page is refreshed.

So, now just search for reasons where you need to have dynamic content, like content is dependent on the users previous actions and etc..,


  1. How can I pass data retrieved from a database by a servlet to a JSP page?
    Thanks in advance.....

  2. This comment has been removed by a blog administrator.

  3. hat is the reason umteen organizations and fill support to outsource impost refreshment programming

  4. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training in India . Nowadays Java has tons of job opportunities on various vertical industry.