Java Servlet JSON Response in JSP using Gson

In Modern web application We get data from 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 for mobile app development. Here we will see how we can get JSON Response from servlet and show in jsp. What is … Read more

ServletContext getting multiple parameters

index.html

web.xml

ServletContext.java

Results

ServletContext getting parameter

index.html

web.xml

ServletContext.java

ServletContext1.java

Results

ServletConfig to access multiple initial parameter value

index.html

web.xml

ServletConfigMulParam

Result

ServletConfig to access 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

Getting servlet header

index.jsp

Header.java

pom.xml

Result

Getting parameter values

Project Explorer : index.jsp

ParameterValues.java

pom.xml

Result

getting all request parameters in servlet

before this we have used request.getParameter(String) which is used to get a single request parameter value. Now if we want to get all parameter names then we have to use request.getParameterNames() it returns Enumeration of String objects of all parameter names. After getting all parameter names we can get its value using request.getParameter(String) . request.getParameterNames() … Read more

Servlet Maven Configuration Example

Maven is the Project Management Tool, that help developers to built the project easily (make create, add, update, compile, testing and deploy work easy).   You can download Maven from Official Site You can find servlet dependency file here Here we will start a new project with maven Project Explorer index.jsp This Jsp page contains a … Read more

Request dispatcher forwarding request

For login example we are using user mail id and password. if both are correct then we are forwaring to home.jsp page if any on of mail id or password is in correct then it will forwarded back to index.jsp page with appropriate error message. index.jsp

Login.java

home.jsp

Result If user id … Read more