1.6 Javaserver Pages (Jsp)


JSP is what happened when somebody introduced Java to HTML, A JSP page looks just like an HTML page,
except you can put Java and Java-related things inside the page. So it really is like inserting a variable into your
HTML (Bates, Sierra and Basham 2008). If we want to repeat previous example with JSP it looks like this:
And output will be:
JavaServer Pages (JSP) is a Sun Microsystems specification for combining Java with HTML to provide
dynamic content for Web pages.
When you create dynamic content, JSPs are more convenient to write than servlets because they allow you
to embed Java code directly into your HTML pages, in contrast with servlets, in which you embed HTML
inside Java code. JSP is part of the Java 2 Enterprise Edition (J2EE) (bea 2002).

1.6 Javaserver Pages (Jsp)


So, with JSP we can solve the issue of formatting HTML into a string in servlet, also web designer is more
familiar with JSP as they know HTML but doesn't know Java.
Actually JSP page will be a servlet at the end of story, which means that a JSP is a servlet that you don't
create. The Container looks at your JSP, translates it into Java source code, and compiles it into a full-
fledged Java servlet class (Bates, Sierra and Basham 2008).
But you have got to know what happens when the code you write in the JSP is turned into Java code. You
can write Java code in your JSP, but should you? And if you don't write Java code, then what do you write?
How does it translate into Java code? All this questions will be answered in the coming topics (Bates, Sierra
and Basham 2008).