| There
is something to be said for the sharing
of knowledge. While this isn’t a massive
world-wide project like the first dictionary
or encyclopedia, I’d like to think
it will have a use, in spite of me. This
article series is about the sharing of knowledge,
and has been called “The Encyclopedia
of Web Technologies.”
I only wish I could be quite that exhaustive;
however, since I’ve already written
more than 100 pages of text, I figure, why
stop now? This time around, we continue
to look at Server-Side Scripting languages
which, without sounding glib, allow you
to add some form of basic intelligence to
your website.
We continue to explore technologies which
enable you to make HTML, CSS and JS dynamically
and in an automated manner. There are many
sites — from Ebay.com to your local
search engine — which use Server-Side
Programming to automatically create the
pages you asked for, exactly the way you
asked for them. Each of the technologies
in both our last article and this one can
really do “anything;” it is
really up to the programmer to measure the
advantages and disadvantages in relation
to the current project.
Let’s move on then, shall we?
JSP Definition
JSP is a Sun Microsystems technology.
You know Sun; it’s the company behind
Java. It’s a good company, and JSP
expands on an already good technology. JSP
is a free specification for extending Java
Servlets to generate dynamic web pages on
a web server.
Like most of our other technologies, JSP
lets developers create dynamic HTML or XML
pages that combine static page elements
with dynamic content. This allows smart
developers to separate user bits like HTML
from logic bits, such as the JSP code. JSP
was created to simplify the Java Servlets
technology (which we’ll cover in a
future article) and to be less complicated
than other offerings, CGI being one example,
available at the time of its creation.
What It Really Is
So we understand that JSP is an extension
of Java for web pages, but what is it really
about? For most people, Java’s biggest
appeal is that it can tie into existing
Java elements, and therefore save a lot
of development time.
JSP is based on components. It uses JavaBeans
and Enterprise JavaBeans (EJB) components
which hold the business logic for an application.
JSP composes tags and a scripting platform
for presenting the content generated and
returned by the beans into HTML pages. The
components structure means that non-Java
developers can use JSP to manipulate beans
built by Java developers. On the other hand,
Java developers can use these beans and
Java in JSP pages for more advanced productions
based on the beans.
A
common JSP rollout would look something
like this:
BROWSER <-> JSP PAGE <->
BEANS/ELEMENT <-> DATABASE |
What is really happening in this process?
A user calls a JSP page through their browser.
Then Resin (for instance) located on the
web server converts JavaScript, JSP tags,
and HTML into segments of Java code, which
the engine consequently arranges into a
core Java servlet. This core servlet is,
therefore, pre-assembled and works “behind
the scenes.” It is called every time
that particular page is requested by a user,
saving valuable recompiling time. The next
time a user calls that page from their browser,
the JSP code has already been compiled,
and it does not have to convert the JavaScript,
HTML, etc. each time. That is, the servlet
engine needs only to produce that servlet
once, or after the last code change was
implemented.
JSP uses a combination of XML and CFM-like
tags, as well as scripts written in Java,
to generate page content. Applications written
to the JSP specification can be run on compliant
web servers, and web servers such as Apache,
Netscape Enterprise Server, and Microsoft
IIS that have had Java support added.
Advantages
+ Strong integration with JavaBeans and
other elements
+ Ease of use for experienced Java developers
+ Rapid Application Development
+ Adept scaling to heavy loads
+ Cross-platform compatibility
+ Open Source availability
Disadvantages
+ Slower speed due to being more robust
and intensive (JSP pages often run slower
than
similar
pages using technologies such as PHP,
for example)
+ Steeper learning curve when compared
to many other technologies
Examples
For a multitude of examples of PHP usage,
as well as a full manual, go to php.net/manual.
Following are some standard types of things
you might find.
Including
a File
<%@ include file="dukebanner.html"
%> |
| Conditionally
Including a File
<%
if ( request.getParameter("username")
!= null )
{
include file="response.jsp"
}
%>
|
Custom JSP Tag
<jsp:setProperty name="numguess"
property="*" />
|
Similar Technologies
In reality, any Net-based scripting language
is somewhat similar to JSP in that it fulfills
the same goals, and we will look at most
of these in future articles within this
series:
+ ColdFusion: ColdFusion is Macromedia’s
offering for web-based dynamic content.
While technically, it isn’t “scripting,”
as it is based on an HTML-like tag structure,
it still fulfills the same goal of providing
dynamic webpages.
+ PHP: Just like JSP, PHP is cross-platform
compatible. In some ways, it is simpler
to develop, because it doesn’t require
separate files for logic and procedures.
It is also is harder to work with for
basically the same reason. PHP is a very
strong language with an incredibly large
and supportive community
|