|
|
Previous<
8
9
10
11
12
13
14
15
16
17
18
> Next |
|
JSP simply puts Java 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 your first JSP.
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 only happens once, so after the first load, the file doesn't take long to load anymore. (But everytime you change the JSP file, it will be re-compiled again.)
|
|
|
|
Java servlets are more efficient, easier to use, more powerful, more portable, and cheaper than traditional CGI and than many alternative CGI-like technologies. (More importantly, servlet developers get paid more than Perl programmers :-).
- Efficient. With traditional CGI, a new process is started for each HTTP request. If the CGI program does a relatively fast operation, the overhead of starting the process can dominate the execution time. With servlets, the Java Virtual Machine stays up, and each request is handled by a lightweight Java thread, not a heavyweight operating system process. Similarly, in traditional CGI, if there are N simultaneous request to the same CGI program, then the code for the CGI program is loaded into memory N times. With servlets, however, there are N threads but only a single copy of the servlet class. Servlets also have more alternatives than do regular CGI programs for optimizations such as caching previous computations, keeping database connections open, and the like.
- Convenient. Hey, you already know Java. Why learn Perl too? Besides the convenience of being able to use a familiar language,
|
|
|
|
JSP is easy to learn and allows developers to quickly produce web sites and applications in an open and standard way. JSP is based on Java,an object-oriented language. JSP offers a robust platform for web development.
Main reasons to use JSP:
Multi platform
Component reuse by using Javabeans and EJB.
Advantages of Java.
You can take one JSP file and move it to another platform,web server or JSP Servlet engine.
|
|
|
|
The advanced servlet and JSP tutorials on this page are based on Marty's book More Servlets and JavaServer Pages, and have been tested by Marty in live training courses in the US, Canada, Australia, Puerto Rico, Japan, Mexico, and the Philippines. See the training materials home page for beginning and intermediate servlet and JSP tutorials, Jakarta Struts tutorials, Apache Tomcat tutorials, JSF tutorials, Java 5 & Java 6 tutorials, and tutorials in Chinese and Japanese.
|
|
|
|
JPS pages are high level extension of servlet and it enable the developers to embed java code in html pages. JSP files are finally compiled into a servlet by the JSP engine. Compiled servlet is used by the engine to serve the requests.
javax.servlet.jsp package defines two interfaces:
|
|
|
|
| Previous< 8 9 10 11 12 13 14 15 16 17 18 > Next |
|
|
|
|
|
|
|
|
|
|