How to access ServletContext parameters

index.html

web.xml

ServletContext.java

ServletContext1.java

Results

How to access ServletConfig initial parameter value

java servlet are executed when user request for some resource in server. ServletConfig is interface defined in javax.servlet package. ServletConfig is used to access servlet’s initial value stored in web.xml. For each servlet there is one ServletConfig. Initial value for servlet are stored in web.xml with name value pair as follows

initial parameter are … Read more

Java Servlet Response JSON in JSP using Gson

In Modern web applications, We get data from the server in JSON format and display data in JSP or HTML page using Front end library or frameworks like Angular, React, etc. This is similar to mobile app development. Here we will see how we can get JSON Response from the servlet and show it in … Read more

Submitting data to servlet using http post

Data sent using http post method is not visible at browser address bar index.jsp

Register.java

Request dispatcher in Servlet User Login Example

Request dispatcher in Servlet is one of the important topics here we explained it using the User login example. In Java Servlets, a RequestDispatcher is an interface provided by the Servlet API that allows you to forward or include a request or response from one servlet to another servlet, JSP (JavaServer Pages), or any other … Read more

Getting parameter values in Servlet getParameterNames

Project Explorer : index.jsp

ParameterValues.java

pom.xml

Result

Servlet url and class mapping using web.xml

We can map url pattern with servlet class at web.xml. Following example will illustrate this. Project directory structure is as below: index.jsp

web.xml

Welcome1.java

In web.xml url pattern(welcome1) will match to a logical name(welcome) that logical name is matched with servlet fully qualified class name(ebhor.servlet.Welcome1). Result: