JSP – Getting Started


This post will help any jsp beginner or students to start with JSP

1) What is JSP(Java Server Pages) ?

JSP is a java technology which is used to develop web pages with dynamic web contents . JSP based applications are platform independent. JSP separates programming logic and the designing part. The syntax of JSP contains Standard HTML or XML and Java codes. JSP files typically have an extension of .jsp.

One of the main advantage of JSP is that Designer and Programmer(Developer) can  concentrate on their work only. Developer mainly concentrates on the dynamic behaviour and XML tags. Designer mainly concentrates on graphics , HTML etc.

2) Softwares required.

The first tool you will need obviously is JDK.

Next is the web server, Apache or Tomcat for JSP hosting (Stable and Open Source). Other servers that supports JSP hosting are IBM’s WebSphere , BEA Weblogic , Sun’s Sun Java Application Server , all these server require a license before you use.

Next for easier use IDE is required for development purpose. There are many editors such as CodeWarrior, Eclipse , JCreater , NetBeans etc.

An ideal total free open source combination is JDK ,Tomcat and NetBeans.

3) Processes in background.

During a request the resulting page will be compiled and executed on the server.  The delivered or the output page will be HTML or XML pages. When client requests  pages the server converts this into servlets and creates instance of servlet which handles users request. Tomcats ‘s Jasper component automatically converts the documents into servlets.

4) Structure of Web Application

J2EE web applications maintains a specific directory structure , so that the same web application can be deployed in any J2EE complaint web server.

Top most is the “ROOT” directory that is all the directoies and files will come under the “ROOT” directory. Inside “ROOT” directory there will be a “WEB-INF” directory.

Any files under “WEB-INF” directory is not directly accessible from a browser by specifying the URL However content of the “WEB-INF” directory is accessible for classes in the application.

“WEB-INF” directory mainly contains three things. They are

1. web.xml – Deployment descriptor.

“web.xml” is called the deployment descriptor which defines servlets, servlet mappings, listeners, filters, welcome files etc.

2. classes directory

The “classes directory” is used to store servlets and other classes of the application.

3. lib directory

The “lib directoty” contains the jar files.

Other directories outside “WEB-INF” but inside “ROOT” are jsp , HTML , Images etc ; the name of these directories can be changed.

When using IDEs all the directories and files will be automatically generated and the user must change the contents of directories and files to suit their needs. If the user is not using any IDEs then he/she must make these directories and files manually.

5) First JSP Program with dynamic content

<HTML>

<HEAD>

<TITLE> First JSP program with dynamic content</TITLE>

</HEAD>

<BODY>

Hello Jsp beginners your time starts now time is

<%= new java.util.Date() %>

</BODY>

</HTML>

First place this jsp file into the folder “jsp” .

“<%= new java.util.Date() %>” :- This the java code that is intermixed with the HTML elements . This is how it make possible to generate web pages with dynamic contents.

Thank you my friends i will be back soon with more interesting topics/tips  in JSP.

Advertisements

Tags: , , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s