What is JSP ?
JSP is the abbreviation of Java Server Pages.
Simply put,
JSP = HTML + Java.
HTML is a markup language & it's features are very limited. It is still simple & superb but can only generate static content. The key concept of a web application, i.e, the Dynamic Content Generation cannot be performed by HTML. So this only happens when it gets some help. To conclude the story, here is viki’s bottom liner.
When the power of Java combined with the simply-superb HTML, the outcome is technically termed JSP.
JSP: Static content
JSP simply puts Java inside HTML pages. You can take any existing HTML page and change its extension to ".jsp" instead of ".html". Take the HTML file you used in the previous exercise. Change its extension from ".html" to ".jsp". Now load the new file, with the ".jsp" extension, in your browser.
You will see the same output, but it will take longer! But only 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 happens only once and after the first load, the file will not take more time to load. (But everytime you change the JSP file, it will be re-compiled again.)
Of course, it is not very useful to just write HTML pages with a .jsp extension!
JSP: Dynamic content
what makes JSP useful is the ability to embed Java. Put the following text in a file with .jsp extension (let us call it hello.jsp), place it in your JSP directory, and view it in a browser.
<HTML>
<BODY>
Hello! The time is now <%= new java.util.Date() %>
</BODY>
</HTML>
Notice that each time you reload the page in the browser, it comes up with the current time.
The character sequences <%= 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.
Watch a demo below.
Download Video Source: High-Quality : 8 MB
Click below arrow to download….
my html file nly runing properly,,,when i try to run th jsp fie ...i got the 404 error msg,,,pls give the solution
ReplyDelete