Showing posts with label servlets. Show all posts
Showing posts with label servlets. Show all posts

Wednesday, 11 July 2012

Java Training: - What are the different scopes of an object can have in a JSP page?

There are four scope which an object can have in a JSP page:-

Page Scope

Objects with page scope are accessible only within the page. Data only is valid for the current response. Once the response is sent back to the browser then data is no more valid. Even if request is passed from one page to other the data is lost.

Request Scope

Objects with request scope are accessible from pages processing the same request in which they were created. Once the container has processed the request data is invalid. Even if the request is forwarded to another page, the data is still available though not if a redirect is required.

Session Scope

Objects with session scope are accessible in same session. Session is the time users spend using the application, which ends when they close their browser or when they go to another Web site. So, for example, when users log in, their username could be stored in the session and displayed on every page they access. This data lasts until they leave the Web site or log out.

Application Scope

Application scope objects are basically global object and accessible to all JSP pages which lie in the same application. This creates a global object that's available to all pages. Application scope variables are typically created and populated when an application starts and then used as read-only for the rest of the application.

See the following video on getting started with servlet: -



Click to get Java Training

Regards,

Get more Java training stuffs from author's blog

Thursday, 21 June 2012

Java Training: -Elaborate implicit EL (Expression Language) objects in JSP?

Following are the implicit EL (Expression Language) objects:-

Page Context: The context for the JSP page.

Provides access to various objects for instance:-

servletContext: The context for the JSP page's servlet and any web components contained in the same application
.
session: The session object for the client.

request: The request triggering the execution of the JSP page.

response: The response returned by the JSP page. See Constructing Responses.

In addition, several implicit objects are available that allow easy access to the following objects:

param: Maps a request parameter name to a single value

paramValues: Maps a request parameter name to an array of values

header: Maps a request header name to a single value

header Values: Maps a request header name to an array of values

cookie: Maps a cookie name to a single cookie

initParam: Maps a context initialization parameter name to a single value

Finally, there are objects that allow access to the various scoped variables described in Using Scope Objects.

page Scope: Maps page-scoped variable names to their values

request Scope: Maps request-scoped variable names to their values

session Scope: Maps session-scoped variable names to their values

application Scope: Maps application-scoped variable names to their values

For instance the below snippet will indentify the browser used by the client.

See the following video on overview and working of Servlets: -



Click to get Java/Servlets Training

Regards,

Get more Java/Servlets training stuffs from author's blog

Thursday, 17 May 2012

Java Training: -Show JDBC (Java Database Connectivity) and its different section?

JAVA interacts with database using a common database application programming interface called as JDBC. JDBC allows a developer to write applications that is database independent. So the developer will be interacting with JDBC API rather than getting in to complications of the database.JDBC allows you to write Java code, and leave the platform (database) specific code to the driver. JAVA was designed to be platform independent and JDBC takes java one step ahead making java database code database independent. That means if you use JDBC for connectivity for SQL Server you can run the same code without changing for ORACLE.


Figure: - JDBC as a layer
Different sections in JDBC: -
There are four major components in JDBC. Below is the diagram which shows the four major sections and the way they interact to achieve the final “resultset”.

Figure: - JDBC in detail

Driver manager section creates the connection object. Connection object create the statement object with the required SQL which is then executed against the database. And finally database gives the result back in the resultset.

See the following starter video on Servlet: -



Click to get Java Training

Regards,

Get more Java training stuffs from author's blog

Friday, 20 April 2012

Java/Servlets interview questions: -Mention differences between getSession(true) and getSession(false)?

Session's can be considered as a series of related interactions between client and the server that take place over a period of time. Because HTTP is a stateless protocol these series of interactions are difficult to track. That’s where we can use HttpSession object to save in between of these interactions so that server can co-relate between interactions between clients.

Figure: - Session code walkthrough

Above is the code snippet which displays session data. Step1 returns an HttpSession object from the request object. “true” parameter in the “getsession” function ensures that we get a session object if there is no current session object in request which ensures that we never get a null session object. In Step 2 we are using the “getattribute” function to return the session value. In step 3 we are setting the session value with “Name” key.

See the following video on Java which describes Hibernate and it concepts: -



Click for more Java/Servlets interview questions

Regards,

Visit for more author’s blog on Java/Servlets interview questions

Tuesday, 6 March 2012

Java Interview Questions: – Elaborate configuration of JSF application in web.xml?

URL containing faces is mapped to FacesServlet which will perform the required task when invoked.

Following are the important entries










Additional entities are made as context param



See the following video on Inheritance between beans and Spring: -



Click for more Java interview questions

Regards,

Visit for more author’s blog on Java interview questions

Tuesday, 15 November 2011

Java/servlets interview questions: - Session tracking and methods for session tracking.

This is one of the asked Java/J2EE interview questions during an interview. So one can start proceeding with the answer as follows.

Session tracking is a mechanism that servlets use to maintain state about a series requests from the same user across some period of time

Following are the methods for session tracking: -
  • User Authentication - occurs when a web server restricts access to some of its resources to only those clients that log in using a recognized username and password.
  • Hidden form fields - fields are added to a HTML form which is not displayed in the client’s browser. When the form containing the fields is submitted, the fields are    sent back to the server.
  • URL rewriting - every URL that the user clicks on is dynamically modified or rewritten to include extra information. The extra information can be in the form of extra path information, added parameters or some custom, server-specific URL change.
  • Cookies - a bit of information that is sent by a web server to a browser and which can later be read back from that browser.
  • HttpSession- places a limit on the number of sessions that can exist in memory.

See the following video on Value List Handler as follows: -



Click and get to see more on  Java/J2EE interview questions series.

Regards,

Also visit author’s blog for more Java/J2EE interview questions

Thursday, 25 August 2011

Java interview questions: - What are the difference between Servlet and Restfull web service?

Servlets are API which is simple and provides capabilities to write server side components.

Rest provides higher level support for writing services which are denoted by using the concept of resource which represents a concept to be addressed while representation indicates the current state of resource. Also Rest provides other facilities like seperation of concerns between client and server, uniform interface,stateless,Caching capability and layered architecture.

View the following video on Web services: -



Get more on java interview questions