JSP : Java Glossary

go to home page J words local find full screen, hide local find menu Google search web for more information on this topic jump to foot of page translate this page with Babelfish punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all) ©1996-2009 Roedy Green, Canadian Mind Products
JSP
Java Server Pages is a language similar to Microsoft’s ASP for creating dynamic web pages. Sun has created a language specification. With JSP, a single source textfile is created containing both HTML (or XML) tags and Java-like scriptlets. The JSP-aware web server composes, compiles and runs a Servlet from the source text. For increased efficiency, the JSP-aware server will typically cache the compiled Servlets. The compiled form are perfectly ordinary Servlets, and thus can be mixed in with ordinary Servlets.

Part of the magic of JSP is that you can replace JSP source code on the fly while the server is active. The next time a request comes for that JSP code, will be automatically recompiled. You don’t have to shut down the server ever time you change the text or JSP markup of a page. This works because of clever use of classloaders to see that obsolete classes are garbage collected. Normally, you use this feature only for testing. You normally don’t update your code while a production server is running.

Multiple Languages Gotchas
HelloJspWorld.jsp advantages
Tags Disadvantages
Two Types of Include Books
Potential of JSP Learning More
Alternatives To JSP Links

Multiple Languages

To master JSP, you need to master several languages:

Hello.jsp

Here is a the JSP equivalent of the HelloWorld program.
See servlet for instructions on how to install and run it. The Servlet womb will automatically convert the *.jsp to *.java and compile it to a *.class file.

Note how it looks like ordinary HTML with dynamically generated variable content Java code enclosed in <%=… %>. Inside those delimeters is a Java expression, called a scriptlet, that when evaluated will produce a String to insert at that point in the HTML file. Have a look at how various JSP files expand into Java source code to generate and glue the various bits of text together. In addition there are other things called tags you can embed with many different syntaxes. Unfortunately, the documentation on how to use them reads like the ramblings of someone with ADD. They keep wandering off on tangents before they have explained the core functionality. Further they scrupulously avoid using examples to explain the abstract gibberish. This is ad hoc language creation at its worst.

By default the Servlet generated is thread-safe so the same code can process several requests simultaneously. Alternatively, you can declare your code with <%@ page isThreadSafe="false" %> so that your Servlet will only be used to process one message at a time.

Note that the <%=%> delimiters used by JSP are not legitimate HTML. They must be expanded and removed before feeding the page to a browser. (In contrast, static macro markup are legitimate HTML even before expansion and are not removed on expansion.)

There are many different sorts of beast you embed in your HTML. Among them are the following tags:

In that last example, the <tr is just an ordinary table row command, nothing to do with JSP. The JSP part is the ${…}

Tags

A *.jsp file generates an entire page of HTML. Tags generate just a snippet of boilerplate to include in a page. They can have both mandatory and optional parameters, but I have not yet learned how to handle a variable number of parameters. Tags are like macros in other languages. You implement the tag by writing a class that extends javax.servlet.jsp.tagext.TagSupport. The Javadoc is inscrutable. You will have to figure out what it means from examples and web tutorials. You also have to write a *.tld (Tag Library Descriptor) file, containing XML to describe the names of the tags, the parameters and the name of the class to process the tag.

There are a number of general purpose tag libraries (taglibs) available on the net that you can access simply by giving the URL of their *.tld files.

Here is how you would invoke a custom tag inside a jsp file:

You can have one-liner bodyless tags or begin-end tags enclosing a body. The body is like a large parameter, often of text to format. The syntax is borrowed from XML.

You must enclose parameters in either " or '. If the attribute value itself contains "s, you must enclose the parameter value in '. If the attribute value itself contains 's, you must enclose it in ". What do you do if a string contains both " and '? You must use the entity &quot; for embedded " and surround the string in "s, e. g.:
<mytag:album title="Sargeant Pepper's Lonely Hearts Club Band">
<mytag:album title='"The Wall"'>
<mytag:album title="Peter's &quot;Weird Songs&quot;">

Two Types of Include

<jsp:include> is a dynamic, runtime/request time include. It invokes another class to produce a page and includes that result embedded in the page output.

<%@ include> is a macro-style, in-line, translation/compile time include that inserts some JSP/HTML source code into the current JSP program.

Potential of JSP

I don’t think websites have even begun to exploit the power of JSP yet. Here are some things you potentially could do with it:

Alternatives To JSP

There are two basic alternatives to JSP:
  1. Ones that also rely 100% on server side computing, such as Velocity, Tea and Freemarker and other frameworks. There are scores of lemmings all going for the fundamentally flawed, but easy to implement, 100% server side solution. You can see a list of them under servlet wombs.
  2. Ones that use a combination of server side and client side computing such as Canoo. Flash is about the only mainstream alternative, (unfortunately non-Java), for the combined solution. I have written up a JSP Replacer student project for an all-Java server-controlled client-side validation environment.

Gotchas

Advantages

Disadvantages

I am not the only one who thinks JSP is not the greatest thing since sliced bread. Check out these essays:

Outstanding Questions

Books

book cover recommend book⇒Head First Servlets and JSP: Passing the Sun Certified Web Component Developer Exam
 paperbackhardcover
ISBN13:978-0-596-00540-5impressioncounter978-0-596-51668-0impressioncounter
publisher:O’Reilly recommended
published:2008-08-07
by:Bryan Basham, Kathy Sierra, Bert Bates
A very complete book, partly because it aims to prepare you for the Sun exam. It is also a difficult book.
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz download o’reilly safari American flag
book cover recommend book⇒Core Web Programming, Second Edition
 paperback
ISBN13:978-0-13-089793-0impressioncounter
publisher:Prentice Hall
published:2001-06-03
by:Marty Hall and Gary Cornell
1250 pages. This is a great doorstop of a book. It has a few chapters on client-server programming in Java, and a section of that is on CGI. I have looked at hundreds of Java books and found nothing that deals in depth with client side Java talking to CGI, except Marty’s book. It is really very simple and he does an excellent job of explaining it. Marty has posted all the source code examples from the book for anyone to use. These contain updates and errata fixes you don’t get on the CD-ROM that comes with the book.
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz

book cover recommend book⇒Core Servlets and Java Server Pages
 paperback
ISBN13:978-0-13-089340-6impressioncounter
publisher:Prentice Hall
published:2000-05-26
by:Marty Hall
Complete text of the book available on line in pdf format.
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz

book cover recommend book⇒More Servlets and Java Server Pages
 paperback
ISBN13:978-0-13-067614-6impressioncounter
publisher:Pearson Education
published:2001-12-26
by:Marty Hall
Complete text of the book available on line in pdf format.
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz

book cover recommend book⇒Web Development with JavaServer Pages
 paperback
ISBN13:978-1-930110-12-0impressioncounter
publisher:Manning Publications
published:2001-09-15
by:Duane K. Fields, Mark A. Kolb, Shawn Bayern
A very thorough treatment.
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz

book cover recommend book⇒Java Servlet Programming
 paperback
ISBN13:978-0-596-00040-0impressioncounter
publisher:O’Reilly recommended
published:2001-01-15
by:Jason Hunter, William Crawford
highly recommended. Covers basics of JSP too.
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz download o’reilly safari American flag
book cover recommend book⇒Murach’s Java Servlets and JSP
 paperback
ISBN13:978-1-890774-44-8impressioncounter
publisher:Mike Murach
published:2008-01-21
by:Joel Murach and Andrea Steelman
Presumes Tomcat and Netbeans. That is a disadvantage if you use other tools but a boon if you use them, since so many problems are about the details of configuring and implementation, not the code itself.
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz
book cover recommend book⇒Java 2 Enterprise Edition BibleJava 2 Enterprise Edition Bible
 paperback
ISBN13:978-0-7645-0882-0impressioncounter
publisher:Wiley
published:2002-04-01
by:Justin Couch and Daniel H. Steinberg
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz
book cover recommend book⇒Pure JSP: Java Server Pages
 paperback
ISBN13:978-0-672-31902-0impressioncounter
publisher:Sams
published:2000-06-08
by:James Goodwill
I would not recommend this book. It seems as it were constructed by copy/paste from the spec. It tries to explain things abstractly without even explaining the conventions of his BNF notation. It needs to be rewritten replacing the BNF with concrete, realistic examples. Reading this book is likely listening to a politician trying to avoid a question. It does have examples, but beats around the bush needlessly before getting to the point. Does not cover tags or UEL.
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz

Learning More


CMP homejump to top You can get the freshest copy of this page from: or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror)
http://mindprod.com/jgloss/jsp.html J:\mindprod\jgloss\jsp.html
CMP logofeedback Please email your feedback for publication, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : feedback email
mindprod.com IP:[65.110.21.43]
view BlogYour face IP:[38.107.191.108]
You are visitor number 19,486.