SQL Syntax

Syntax: Syntax is a set of rules and guidelines which defines the structure of statements in a computer language. SQL syntax: SQL syntax is a set of rules and guidelines which defines the structure of SQL statements. SQL is case insensitive. Commonly used SQL commands: 1. SELECT – It is used to extract data from … Read more

Categories SQL

Cookie in servlet

Cookie: A cookie is a small piece of information as a text file stored on client’s machine by a web application. How cookie works? As HTTP is a stateless protocol so there is no way to identify that it is a new user or previous user for every new request. In case of cookie a … Read more

Session management in servlet

Session: The session is a time interval devoted to an activity. Session Tracking: Session Tracking or session management is a way of maintaining the state of the user. Need of Session Tracking: As we discussed in earlier tutorials we are using HTTP to complete request-response cycle. HTTP is a stateless protocol which means when a … Read more

Servlet Hello World Example using annotation

ServletAnnotationExample.java import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * This servlet program is used to print “Hello World” on * client browser using annotations. */ @WebServlet(“/HelloWorld”) public class ServletAnnotationExample extends HttpServlet { private static final long serialVersionUID = 1L; //no-argument constructor public ServletAnnotationExample() { } protected void … Read more

Servlet context parameters and ServletContext interface

Context parameters: Context parameters refer to the initialization parameters for all servlets of an application. <context-param> attribute is used to define a context parameter. <context-param> attribute has two main sub attributes <param-name> and <param-value>. The <param-name> contains the name of the parameter and <param-value> contains the value of the parameter. ServletContext interface: The servletContext interface … Read more

Servlet Init parameters and ServletConfig interface

Init parameters: Init parameters refer to the initialization parameters of a servlet or filter. <init-param> attribute is used to define an init parameter. <init-param> attribute has two main sub attributes <param-name> and <param-value>. The <param-name> contains the name of the parameter and <param-value> contains the value of the parameter. ServletConfig interface: The ServletConfig interface is … Read more

Servlet sendRedirect

sendRedirect() is the method of the HttpServletResponse interface which is used to redirect response to another resource. Syntax: response.sendRedirect(relative url); Difference between sendRedirect and RequestDispatcher.              sendRedirect           RequestDispatcher Creates a new request from the client browser for the resource. Accept relative URLs so control can go inside or outside the server. The new URL … Read more

Servlet RequestDispatcher interface

RequestDispacher is an interface that provides the facility to forward a request to another resource or include the content of another resource. RequestDispacher provides a way to call another resource from a servlet. Another resource can be servlet, jsp, or html. Methods of RequestDispacher interface: 1. forward(ServletRequest request, ServletResponse response): This method forwards a request … Read more

Deleting emails using JavaMail API

We are explaining here an example of deleting emails using JavaMail API. Steps of deleting email using JavaMail API: 1. Get a session instance from getDefaultInstance() or getInstance() method of Session class. 2. Create the store object (POP3) and connect to the pop store. 3. Create the folder object by calling getFolder() method on store … Read more

Forwarding emails using JavaMail API

We are explaining here an example of forwarding emails using JavaMail API. Steps of forwarding email using JavaMail API: 1. Get a session instance from getDefaultInstance() or getInstance() method of Session class. 2. Create the store object (POP3) and connect to the pop store. 3. Create the folder object by calling getFolder() method on store … Read more