Session Tracking in Servlet/JSP

What is Session?

Answer : A specific time span that user interact with the website, is persistent through out that time span.

Servlet serves the request made by the client and generates the dynamic output. But servlet is not capable enough to remember the last client who made the request by own, because it uses the HTTP protocol, which is a stateless protocol.

To make a session a persist, various approaches could be adapted by servlet like…

  • URL Rewriting (Query String) : Session information is persist by modifying query string. (client side)
  • Hidden Fields : Session information is persist using Hidden Fields in form. (client side)
  • Cookies : Session information is persist using Cookies in via browser in client’s computer. (client side)
  • Http Session : Session inormation is persist using Http Seesion object on server .(server side)

– Ravi Oza

 

Important Tag in web.xml

Web.xml file is a configuration file in Java web application, it is used to define application wide and servlet/jsp wide settings.

It is a file referred by container on the server to identify Java resources available when requested by client.

Following is the list routine tags available in web.xml file.

  • <web-app>
  • <servlet>
  • <servlet-mapping>
  • <welcome-file-list>

<web-app> : It is the root tag of all the other tags in web.xml file

<servlet> : It is a sub tag of <web-app> tag, use to define servlets name and class, it has two more sub tags which are <servlet-name> and <servlet-class>

It is also used to declare parameter for the respective servlets, using <init-param> followed by two more sub tags, <param-nam> and <param-value>

<servlet-mapping>

It is use to describes a pattern used to resolve URLs. This tag is to be written inside <web-app> tag and outside of any <servlet> tag.

It is uses two more sub tags such as <servlet-name> and <url-pattern>

<welcome-file-list>

The optional <welcome-file-list> element contains an ordered list of welcome-file elements.

– Ravi Oza

 

Deployment Descriptor

deployment descriptor (DD) refers to a configuration file for an artifact that is deployed to some container/engine.

In the Java Enterprise Edition, a deployment descriptor describes how a component, module or application (such as a web application or enterprise application) should be deployed.

– Wikipedia

It also contains servlet/jsp wide settings as well as application wide settings for enterprise app of Java.

Another name of deployment decriptor is web.xml, resides in WEB-INF folder in the project hierarchy of Eclipse/NetBeans IDE.

Web.xml is a customized tag file. It allows to configure all the the settings in tag format. Such as, Initialization Parameter, Wel come file list for app, Cookies and Session tags etc.,

-Ravi Oza

Java Enterprise Edition

Hello to all readers,

Introduction to Advance Java

Today I am going to discuss about advance Java, is an enterprise edition of Java for developing multi tiered applications. Here tier is like a layer (division or part) of application, generally its use to develop we apps where each layer such as presentation layer, business layer and database layer is scatter around various places.

Let me discuss with an example of a PHP application, where user interface (generally a HTML page) is submit its request to an PHP file where business logic code is written (non OOP manner), that file not only handle the request made by client but also generate the dynamic output. But there are few restriction here because some times it is difficult to mange business logic from your presentation and other. So, Advance Java may help in that regards, first it supports OPPS and allows us to develop the apps in tiered architecture.

Its supports features such as Servlet, JSP, JDBC, EJB and other API to develop robust and distributed enterprise web application. In next post I shall discuss about above feature in brief.

Regards.

R.O.