sendRedirect Method Example in Servlet
We have seen earlier, the usage of include(), forward and their 15 differences. Now let us see how to use sendRedirect() method. The sendRedirect(String URL) is defined in...
View ArticleDifference between forward and sendRedirect Methods
We have seen earlier include() and forward() methods of RequestDispatacher interface with example programs and figurative explanation. 15 differences were shown between include() and forward()....
View ArticleDifference between RequestDispatcher from ServletRequest and ServletContext
We have seen two programs with include() and forward() methods of RequestDispatcher. In both the programs, getRequestDispatcher(String path) of ServletRequest is used to obtain an object of...
View ArticleStateless and Connectionless HTTP Protocol
What is HTTP (HyperText Transfer Protocol) Protocol? A protocol sets standards for communication between systems, client to server or among servers. HTTP is specially meant to communicate between...
View ArticleWhat is Session, Session Tracking, Session Management, JSESSIONID?
For easy understanding, the notes is given in Question/Answer format. 1. What is a Session in Servlets? The interactive time between client and server on a single connection is known as a session. Or...
View Articlerequest.getScheme() Method Example in Servlets
This method is defined in ServletRequest interface from javax.servlet package inherited by HttpServletRequest. With this method, the servlet programmer can know what protocol (like HTTP) is used by the...
View ArticleHTTP Session, HttpSession Methods in Java
Before reading this, it is advised to read the nature of HTTP protocol and what are session, session tracking and JSESSIONID. To maintain session in Servlets, the Java API comes with...
View ArticleHttpSession Example Hit Count
After learning Session, Session tracking, Session ID and HttpSession and its methods, let us write a program to maintain session tracking using HttpSession interface. The aim of this code is, in a...
View ArticleServlet Cookies Simple Shopping Cart Example
Note: You can see the JESSIONID (Session ID) in the output screens at the end. Note: For better understanding, the subject is discussed in Question/Answer format. Note: Before going into this example,...
View ArticleJava Servlet Cookie API Methods
Before going into the API, first let us know what for Cookie is? For better understanding the subject is discussed in Question/Answer format. 1. What is Cookie? For us, Cookie is a class from...
View ArticleServlet Life Cycle Tutorial with Methods
1. What is Servlet life cycle? Definition: Different states in which a Servlet exists between its object creation and object garbage collection is known as life cycle of Servlet. 2. Who is responsible...
View ArticleServlet Life Cycle Example with Database Connectivity JDBC
After learning what Servlet life cycle is and the methods involved, let us go for an example involving the life cycle methods. I take the opportunity to connect to database and read table records using...
View Articlerequest.getRemoteAddr() Method Example in Servlets
This method is defined in ServletRequest interface from javax.servlet package inherited by HttpServletRequest. With this method, the servlet programmer can know the IP address of the client from which...
View ArticleServlet getHeaderNames() and getHeader() Simple Example
Header Information When a client clicks a hyper link or a submit button, we know that the data entered by the user in the Form fields is sent to server and is the default behaviour of submit button....
View ArticleServlet WAR File in Tomcat with Creation, Deployment, Execution
We have seen earlier what a JAR file is, its options, creation and advantages in JAR (Java ARchive) Files. Now let us study what a WAR file is and its creation etc. WAR stands for Web ARchive. A WAR...
View ArticleSending Image to Client from Servlet Example
So far all the earlier examples, we used to send text or HTML messages (text/html) to client. Now-a-days, images are also playing important role in client/server communication. For example, you go to...
View ArticleServlet WAR File in Weblogic Creation and Deployment
With the release of the Java Servlet Specification 2.2, the concept of a Web application was introduced. According to this specification, a "Web Application is a collection of servlets, html pages,...
View ArticleServlet Read text file and Return contents to Client Example
Sometimes, the client may ask the Servlet to send the file contents of a file existing on the server. It is not file download. Here, the Servlet reads manually line-by-line and send each line...
View ArticleServlet Read HTML File Contents Example
Earlier we did a program where client requested for a text file; but the case now is with HTML file. If the user sends a request for HTML file, when it comes to the browser, it is interpreted and...
View ArticleStatus bar Applet showStatus() method Example
Displaying messages is of two ways in Applet. One way is displaying anywhere in the applet window and the other way is displaying in the status bar. The bottom of the applet window is known as status...
View Article