Wednesday, October 28, 2015

JSP Page Directive

JSP page directive: The page directive in JSP is used by programmers to get the structure of the auto generated servlet modified according to their requirements. It has following syntax: Commonly used attributes of the page directive are: 1. import: This attribute is used to get the specified packages imported in the auto generated servlet […]
Read Complete Post...

Tuesday, October 27, 2015

JSP include directive

JSP include directive? include directive in JSP, is used by application programmers to get the contents of a page included to the current JSP at the time of translation. It has following syntax: You may recall that <jsp:include …/> action also has the same functionality. Now you should be wondering why are both the action […]
Read Complete Post...

JSP Directive

What is a directive? A directive in JSP, represents an instruction to the translator to modify the structure of the auto generated servlet at the time of translation on behalf of the programmer. You have been already told that for each JSP, a servlet class is auto generated. Sometimes modifications are required in this servlet […]
Read Complete Post...

Wednesday, October 7, 2015

Practical example of external objects in JSP

Practical use of external objects in JSP: To demonstrate the use of external objects with the help of useBean, setProperty & getProperty actions, I have created a simple web application. Following diagram describes the flow of application: Description of the diagram: Source code of the application: First, the home page index.html. <b>Rectangle Home</b> <form action="rect.jsp"> […]
Read Complete Post...

Tuesday, October 6, 2015

JSP getProperty action tag


getProperty action of JSP: <jsp:getProperty /> action is used to write the value a bean property to the output stream. It is used when a property value is to be sent as response. It has following syntax: Let following be an external object in a JSP page. To write the value of mailId property of […]
Read Complete Post...

JSP useBean action tag

External objects in JSP: In a JSP page, two types of objects can be used: 1. implicit objects 2. external objects Implicit objects are Servlet & JSP API objects which are made available by default in the _jspService() method. External objects are objects of user defined or library classes which are created in the _jspService() […]
Read Complete Post...

Action tags of JSP

The Action tags of JSP: Action tags in JSP facilitate automation of common operations such as creation of objects, setting objects’ properties, writing objects’ property values to the output stream, including the contents of a component to the response of current request and forwarding request to another component etc. An action tag has following syntax: […]
Read Complete Post...

Monday, October 5, 2015

Expression tag of JSP

The expression tag of JSP: Expression tag in JSP has two use. 1. It is used to write the value of an expression to the output stream i.e. It provides a short hand mechanism of evaluating expressions and writing their values to the response. 2. It is used to assign the value of variables and […]
Read Complete Post...

Declaration tag of JSP

The declaration tag of JSP: declaration tag in JSP facilitate data members and methods definition in the auto generated servlet. Main use of this tag is the overriding of jspInit() and jspDestroy() methods. You have been told that for each JSP a servlet is auto generated at the time of translation. If this class was […]
Read Complete Post...

Saturday, October 3, 2015

Scriptlet tag of JSP

The scriptlet tag of JSP: Scriptlet is the main tag of JSP. It is used to add request processing logic to a JSP page. A JSP page may contain any number of scriptlet tags. It has following syntax: At the time of translation, contents of the scriptlet tags are copied as it is to the […]
Read Complete Post...

understanding JSP life cycle

The JSP life cycle: JSP life cycle is defined by JspPage and HttpJspPage interfaces. Similar to servlet, JSP life cycle has three methods: jspInit(), jspDestroy() and _jspService() . javax.servlet.jsp package contains classes and interface of JSP API. Main classes and interfaces of the JSP API are: JspPage: It extends Servlet interface and provides following JSP […]
Read Complete Post...

Introduction to JSP

Limitations of servlet: Servlet as web application development technology has following drawbacks: 1. Developing web applications using servlet is unproductive i.e. a lot of code need to written even for simple tasks. 2. A servlet is responsible for dynamic content generation as well as presentation. This intermixing of dynamic content generation logic with the presentation […]
Read Complete Post...

Servlet 3 file upload example

Steps required to upload a file: 1. In html form, request type is set to post and enctype is set to multipart/form-data. 2. <input type=”file” > element is used in the html form to facilitate selection of the file from the file system. 3. In the servlet multi part request is parsed to obtain file […]
Read Complete Post...

Practical use of @WebServlet and other annotations

To demonstrate the practical use of servlet annotations, I have created a web application which have two servlets (ProcessingServlet & ForwardingServlet), a listener (HitCounterListener), a filter (HitCounterFilter) and a HTML page (index.html). When the application is deployed, HitCounterListener sets an attribute named hitCount in the application scope to count the no. of hits of the […]
Read Complete Post...

Servlet annotations and their advantages over xml

What is an annotation? An annotation is a class member, the purpose of which is to describe other members of the class. The literal meaning of the word annotation is: a note added to describe or clarify something. In real life we all use annotations. When you write the meaning of a word over it […]
 Read Complete Post...

Filter and request dispatching

Filter and request dispatching: In addition to a direct request, a servlet can be invoked internally through forwarding or inclusion. If a filter is associated to a servlet then will it inovke when a request is internally forwarded to the servlet or its response is included to another servlet’s response? By default, a filter which […]
Read Complete Post...

Practical example of a filter

A scenario for the practical use of a filter: To demonstrate the practical use of a filter in a web application, I am creating a filter which checks the URI of each incoming request. If the request is for the home page or the servlet which authenticates, simply requested component is invoked by the filter. […]
Read Complete Post...
 

What is the role of FilterChain?

What is FilterChain? FilterChain is an interface of the servlet API. Implementation of it, is provided by server vendors. It provides following method: You may recall that the Filter interface also has doFilter() method. That method has three parameters one of which is a FilterChain object. The doFilter() method of the Filter interface is used […]
Read Complete Post...

Filter life cycle and the role of FilterConfig

Filter life cycle: Filter life cycle describes how and when a filter object is created and initialzed, how it performs pre & post processing and how and when it is destroyed by the server. Filter life cycle is defined by javax.servlet.Filter interface with the help of following methods: init(): This method is invoked by the […]
Read Complete Post...

What is a filter?

What is a filter? A filter is an optional component of a web application which is used to perform pre and post processing operations such as logging, validation, flow control etc. Filters are associated to the servlets and HTML pages of the applications. Whenever a request is received for these components, associated filter is invoked. […]
Read Complete Post...