By: aathishankaran in JSP Tutorials on 2007年02月10日 [フレーム]
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.
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Most Viewed Articles (in JSP )
Show a calendar for user input in JSP
Encrypting Passwords in Tomcat using Servlets
JSP Tags for SQL to connect to a database
Steps to get a Free SSL certificate for your Tomcat
Uploading a file to a server using JSP
Server Side Programming using JSP
Latest Articles (in JSP)
Show a calendar for user input in JSP
Steps to get a Free SSL certificate for your Tomcat
Encrypting Passwords in Tomcat using Servlets
JSP Tags for SQL to connect to a database
Uploading a file to a server using JSP
Uploading an Image to a Database using JSP
A JSP page that gets properties from a bean
Scriptlets and Expressions in JSP
The taglib, tag, include, attribute and the variable Directive in JSP
Show a calendar for user input in JSP
Encrypting Passwords in Tomcat using Servlets
Steps to get a Free SSL certificate for your Tomcat
JSP Tags for SQL to connect to a database
Uploading an Image to a Database using JSP
Uploading a file to a server using JSP
© 2023 Java-samples.com
Tutorial Archive: Data Science React Native Android AJAX ASP.net C C++ C# Cocoa Cloud Computing EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Trends WebServices XML Office 365 Hibernate
Latest Tutorials on: Data Science React Native Android AJAX ASP.net C Cocoa C++ C# EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Cloud Computing WebServices XML Office 365 Hibernate