Sie sind auf Seite 1von 11

http://bluehostcouponsplace.

com/

Idiots guide to Web
Environment-JSP

Idiots guide to Web Environment-JSP


JSP-Java Server pages is a server side scripting language. Did
not comprehend what that means? Well, in lay mans language,
jsp is a technology for creating dynamic web pages, which uses
the traditional Http approach of request-response, with all the
business functionality carried out at the server side using java.
Still having a dilemma?
Let us begin with the basics. To view information over the
internet, we require an interface, which we call a browser. This
browser is nothing but an html parser that displays the .html or
.htm file sent by a web server. Now, html is a mark-up language
designed for this sole purpose of displaying the web content. Html
has fixed tags that help in the process and also has the important
tags or even CSS for visually pleasing display of information. Now
what is google? It is that magic box(actually a search engine!)
which will run around the world asking everyone on the internet
and bring you the best answers to your query. You need to have
special web hosting for hosting your JSP files, you can use
Bluehost coupons to save your money easily.
Let us now understand a web server and then we finally move on
to java server pages. A web server is a computer hardware or
software which runs at a remote location, and responds to a
request sent in by the client. Whenever we click a button or view
a page or do any activity on a web page, the data displayed is
provided by the web server processing our request. Html, CSS
and Javascript form a trio where Javascript is basically used for
client-side scripting without the necessity of invoking a servers
help. It can be used to display alerts, for form validation and so
on and so forth.
So now, where does JSP come into picture? To provide better
functionalities, to have speed, security along with reliability,
scalability, interoperability and many other specifications,
different languages for web development came into existence,
each having its unique use, advantage and depending on the
requirement, selection of such a technology can be made. To
name a few popular: php , asp .net, vb .net, jsp. Today, we look
at JSP.
In plain text, jsp is a java based technology that operates at the
server side and aids the server in giving an apt response back to
the client. JSP is java embedded in html. You simply write java
code into html file by using some special characters to mark the
beginning and end of the jsp code. This code is perused by the
server and the processed result is sent back. A jsp file has a .jsp
extension. All the features of java, like its security, object-
oriented approach, and automatic garbage collection are available
in jsp because the jsp code is compiled by a java compiler running
on the server machine. We will soon understand thejsp life-cycle
and the role a servlet plays in it.

Basics of JSP [Java Server Pages]
Those who are familiar with java will have absolutely no problem
with coding in jsp. For others, you need to know java to work with
jsp! Let us understand it in the simplest way possible.
Start in by taking .html file with the required forms, gui, etcetera.
Then code in your jsp using the jsp start and end tags. A jsp code
can be embedded anywhere in the html file. You can write the jsp
code in the head, in the body or between the head and the body.
No restrictions at all!A jsp code can have 4 type of tags:
1) Directives:
They serve the primary purpose of importing the java packages.
2) Declarations:
They are used to make declarations likeintdefault_value=5,
double volume=216.231, etc.
3) Scriptlets:
The scriptlets contain your java business logic.
4) Expressions:
Expressions let us use the value of the JSP variables at different
places in the html code; especially useful for displaying such
values.
Important thing to note here in scriptlets is that we do not write
classes but directly start coding into the scriptlets.
Servlet and jsp life cycle
By now, we know that jsp is java embedded into html. Servlet is
exactly its opposite. It is html embedded in java. We will not look
into its details, but servlet occupies a pivotal place in jsp based
environments.

Fig: JSP Life-Cycle
Jsp life-cycle starts with conversion of jsp into servlet, i.e. into a
.java file. From there on, the jsp lifecycle is exactly like that of
servlets. The .java file is compiled by a java compiler to give a
.class file which when executed, the servlet is first initialized, then
the service method possesses the business logic to be processed
and finally it is destroyed after an apt response has been sent
back to the client.
Some important tips
U can use frameworks like the Adobe Dreamweaver for building
your jsp pages, where the html UI can be built using the
framework but the jsp technology code will have to be written in.
Using a java editor like JCreator or EditPlus and then migrate the
code, is also a viable option.
Never ever write the business logic injsp. This is the first and
foremost thing mentioned by Oracle; and rightly have they
mentioned so. If the business functionalities are in jsp, then
it becomes extremely difficult to port such a webpage or
website, say from desktop to smartphone.
Though a bit tedious, a more efficient and secure method
would be to direct a jsp page to a servlet, which could
perform the desired actions (like accessing a database), just
like a jsp page would have.
Jsp is slower than php, but certainly more secure.
If you are planning to deploy jsp on free web hosting sites, it
may not be possible. The reason is that most of these free
websites do not support jsp.
Even if you plan to buy a server, it has to be a dedicated
one, because a distributed server might not work as you are
not given access to its root folder, thus making it impossible
to add jar files or difficult to make changes. It would be
better to buy a dedicated server, and having an online
database is advisable.
You are now set explore jsp and create your own fervent world!

Read Full Article: http://www.teechworld.com/idiots-guide-to-
web-environment-jsp/

Das könnte Ihnen auch gefallen