The JSP Program running first Time.

By: aathishankaran Emailed: 1589 times Printed: 2039 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

The JSP Program running first Time.

 JSP program is just simply puts Java code inside HTML pages.  You can take any existing HTML page and change its extension to ".jsp" instead of ".html".  In fact, this is the perfect exercise for programming in JSP.

Take the HTML file and Change its extension from ".html" to ".jsp".  Now load the new file, with the ".jsp" extension, in your browser. Now you can view the jsp page as a web page.

You will see the same output, but it will take longer!  It happens only at the first time.  If you reload it again, it will load normally.

What is happening behind the scenes is that your JSP is being turned into a Java file, compiled and loaded.  This compilation only happens once, so after the first load, the file doesn't take long to load anymore.  (But at every time you change the JSP file, it will be re-compiled again. Because jsp file shout compiled whenever we change the code.)

Of course, it is not very useful to just write HTML pages with a .jsp extension!  We now proceed to see what makes JSP so useful.

Adding dynamic content in html page

As we saw in the previous, any HTML file can be turned into a JSP file by changing its extension to .jsp.  Of course, what makes JSP useful is the ability to embed Java.  Put the following text in a file with .jsp extension (let us call it hai.jsp),

First place the file into your JSP directory, and view that file in your browser. 

 

<HTML>
<HEAD>hai</HEAD>
<BODY>
Hello!  The time is now <%= new java.util.Date() %>
</BODY>
</HTML>
 

Note it at each time you reload the page in the browser, it gives the current time in the browser.

The character sequences is can embed by using this tag <%= and %> enclose Java expressions, which are evaluated at run time.

This is what makes it possible to use JSP to generate dynamic HTML pages that change in response to user actions or vary from user to user.


JSP Home | All JSP Tutorials | Latest JSP Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(1)


1. View Comment

please give me more information

View Tutorial          By: nandhini at 2012-09-22 03:49:11

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by aathishankaran
Web Security Issues
The Web User's Perspective
Server-side plug-Ins
The best way to avoid security vulnerabilities with new server
JavaScript Security
Window Object
Working with Status Bar Messages
Retrieving a Portion of a String
Referencing Windows
Math Object
Frame Object
Document Object
Closing Windows
Built-in Object in Javascript
Textarea Object

More Tutorials in JSP
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: `java.net.BindException: Permission denied <null>:80
JSP Alert Example
JSP CheckBox Example
Uploading an Image to a Database using JSP
Uploading a file to a server using JSP
A JSP page that gets properties from a bean
The page Directive in JSP
The taglib, tag, include, attribute and the variable Directive in JSP
Declarations in JSP
Scriptlets and Expressions in JSP
Tag Libraries in JSP
The Request Object in JSP
The Response Object in JSP
The Out Object in JSP
The Session Object in JSP

More Latest News
Most Viewed Articles (in JSP )
JSP Example to connect to MS SQL database and retrieve records
What are the different scopes in JSP?
JSP Alert Example
JSP CheckBox Example
Comparison operators in JSP
JSP Program for display Date
Uploading a file to a server using JSP
The Advantages of JSP
Uploading an Image to a Database using JSP
Sending Email using JSP
Writing your first JSP page
Getting Started with JSP
Arithmetic Evaluation Using the Expression Language in JSP
The BodyTag Interface in JSP
The JSP Program running first Time.
Most Emailed Articles (in JSP)
Click to Activate and Use this control
HttpClient
NotifyUtil::java.net.ConnectException: Connection refused: connect
Comparison operators in JSP
Document Object
Embedding java codes in jsp sciptlets
Form processing in JSP
JSP Program for display Date
The Servlet Life Cycle
Enable/Disable Scripting Elements in JSP
Steps to get a Free SSL certificate for your Tomcat
Cookies using JSP or Java Bean
The JSP Program running first Time.
JSP pages in servlet
Sessions in JSP