Tagged: #servlet

Download file from a Web Application using Servlet

This tutorial shows how to download a file from a web application using Servlet. A typical task in most web applications is to download files stored at the server side to the client’s machine, here below we provide the common way of doing this with Servlet. 1- Download File Servlet Below is an example of a typical Servlet which downloads files...

How to exclude a URL from a Filter

By default, filters doesn’t support excluding a specific URL pattern, whenever you define a URL pattern for a filter then any request matching this pattern is handled by the filter without exceptions. The simplest way for excluding URLs from a filter is to map your filter to a very specific pattern. This is feasible when done in early development stages,...

forward() vs sendRedirect() vs include()

It is a common practice that a controller redirects to another resource after processing a request, the resource could be either a view which displays the result of processing or even another controller which needs to do further processing on the request. In this tutorial, we explain the different ways of redirecting requests from servlet to another resource. Basically we...

Pass data from servlet to jsp

JSP is mostly used as the view component in any java-based MVC application, its main usage is to present dynamic data processed and generated from server-side controllers like servlet. In this tutorial, we explain the different ways of passing attributes/parameters from servlet to JSP, along with several examples specific for passing data types like: objects, arrays, lists and maps. 1....

Pass data from javascript to servlet

In modern web applications, the data exchange between front-end and back-end is usually done dynamically through javascript. In this tutorial, we explain 2 ways of exchanging data between javascript and java servlets, we also provide an example and business cases for the usage of each way. 1. Submit form programatically The first case is when you already have an html...

Pass data from html to servlet

In this tutorial we explain the common way of passing data from html to java servlets, we mostly focus on passing form data entered by end-users through pages like: login, sign-up, contact-us .. 1. Pass form fields to servlet Consider the following login.html:

Users interact with web applications through forms, the “form” element is the common way for asking end-users...

JSP – Hello World Tutorial

In this tutorial, we provide a step-by-step guide for creating a hello world web application using JSP technology. Prerequisites: Eclipse IDE (Mars release) Java 1.7 Apache tomcat 7 1. Create dynamic web project Open eclipse, then select File -> New -> Dynamic Web Project. In the next screen, fill the mandatory fields as above, you are free to choose any...

Servlet 3.0 – Hello World Tutorial

In this tutorial, we provide a step-by-step guide for creating a hello world web application using Servlet 3.0 technology. Servlet 3.0 supports defining and exposing servlets using annotations, if you still love to define servlets manually, refer to our previous tutorial about creating web applications using servlet 2.5. Prerequisites: Eclipse IDE (Mars release) Java 1.7 Apache tomcat 7 1. Create...

Servlet 2.5 – Hello World Tutorial

In this tutorial, we provide a step-by-step guide for creating a hello world web application using Servlet 2.x technology. Prerequisites: Eclipse IDE (Mars release) Java 1.7 Apache tomcat 7 1. Create dynamic web project Open eclipse, then select File -> New -> Dynamic Web Project. In the next screen, fill the mandatory fields as above, in case you didn’t previously...