Login Example: JSP and Servlets: Part II.

Hello Friends,

This is part II of jsp and servlets login example. Check Part I here.

Step 4) Now, we need to create a Servlet file for the redirection of the jsp pages. In the src folder under the package code2java, add the Servlet file and name it as LoginServlet. As discussed earlier this servlet file will get the user details from the Bean file and then it will create a Session for that user only if the user is a valid user. And accordingly it will redirect to the respective jsp pages. You can use the default code which Eclipse generates while Servlet creation, the only change you need to do is in doGet() method. Continue reading “Login Example: JSP and Servlets: Part II.”

Login Example – JSP and Servlets: Part I.

Hello Friends,

This is one of the tutorials on JSP and Servlets. In this we will discuss and create a simple login application using servlets and JSP where we will connect to the DB for the user credentials and then authenticate the users accordingly. First of all we will discuss about what we will need for this.

JSP Pages:

We will create three JSP pages which will be the only viewable parts of our code. The three pages will be as Login Page, Login Success page and the Invalid Login page. Continue reading “Login Example – JSP and Servlets: Part I.”

JSP Redirection from a Servlet.

Hello Friends,

This tutorial is regarding the jsp redirection from a Servlet to a another jsp page. Most of you may need to redirect the user to a jsp page being on the servlet page. This tutorial will help you. There are two ways to achieve this, we will discuss them both.

Continue reading “JSP Redirection from a Servlet.”

Servlet program using Eclipse IDE.

Hello Friends,

This tutorial is regarding development of Servlet program using Eclipse IDE. Eclipse IDE is very popularly used for development of various web based and java applications. Servlet applications are very easily developed using the eclipse IDE. Following are the simple steps for the same.

Step 1) Open the Eclipse IDE and set the Perspective to Java EE (if not set by default). Continue reading “Servlet program using Eclipse IDE.”

Life Cycle of the Servlet.

Hello Friends,

This is one of my tutorials on Servlet. As we all know, servlets are managed by the web container and among the various responsibilities of the container, life cycle of servlet is the most important one. The life cycle defines that how the servlet is loaded, instantiated and initialized, how it handles requests from clients and how it is taken out of service. The servlet’s life cycle methods are defined in the javax.servlet.Servlet interface which is implemented by every Servlet class by extending the abstract classes – “GenericServlet or HttpServlet”. Continue reading “Life Cycle of the Servlet.”

URL Mapping in Servlets.

Hello Friends,

This is one of the interesting tutorials regarding the URL Mapping in Servlets. The thing which makes this interesting is that, the URL that one click on the browser is not the real one but still it displays the result on his interest. This is no magic but the advantage of Servlet that avoids the direct linking to the actual page for the client.

The URL comes within the Servlet Request whenever the link is clicked (or the Submit button is clicked or similar event that navigates the browser to a new page). Now, the question is that How Container knows which url should be mapped with the response. The answer for this is present in the Deployment Descriptor or DD. Continue reading “URL Mapping in Servlets.”

Introduction to Java Servlets.

Hello Friends,

This is my first tutorial on the Java Servlets. This will be helpful for all the newbie who wants to learn the advance java programming. This is the first and basic step to enter the java enterprise environment. In this tutorial we will be focusing on what actually are servlets, what are its advantages some simple things related to Servlets. Continue reading “Introduction to Java Servlets.”