Well in this speech I want to talk about spring boot and everything it is necessary you know that.
What is a Servlet?
Servlet can be described in many ways, depending on the context.
A web application is an application accessible from the web. A web application is composed of web components like Servlet, JSP, Filter, etc. and other elements such as HTML, CSS, and JavaScript. The web components typically execute in Web Server and respond to the HTTP request.
CGI technology enables the web server to call an exteal program and pass HTTP request information to the exteal program to process the request. For each request, it starts a new process.
There are many problems in CGI technology:
There are many advantages of Servlet over CGI. The web container creates threads for handling the multiple requests to the Servlet. Threads have many benefits over the Processes such as they share a common memory area, lightweight, cost of communication between the threads are low. The advantages of Servlet are as follows:
-What information is received by the web server if we request for a Servlet? When a request is made, the Sun Java System Web Server hands the incoming data to the servlet engine to process the request. The request includes form data, cookies, session information, and URL name-value pairs, all in a type HttpServletRequest object called the request object.
-What are the ways for servlet collaboration and what is the difference between RequestDispatcher and sendRedirect() method?The RequestDispatcher interface allows you to do a server side forward/include whereas sendRedirect() does a client side redirect.
SendRedirect() will search the content between the servers. it is slow because it has to intimate the browser by sending the URL of the content. then browser will create a new request for the content within the same server or in another one.
RquestDispatcher is for searching the content within the server i think. its the server side process and it is faster compare to the SendRedirect() method. but the thing is that it will not intimate the browser in which server it is searching the required date or content, neither it will not ask the browser to change the URL in URL tab. so it causes little inconvenience to the user.
What is the difference between ServletConfig and ServletContext interface? But, the difference lies in the fact that information shared by ServletConfig is for a specific servlet, while information shared by ServletContext is available for all servlets in the web application.
A filter is an object used to intercept the HTTP requests and responses of your application. By using filter, we can perform two operations at two instances −
The following code shows the sample code for a Servlet Filter implementation class with @Component aotation.
@Component
public class SimpleFilter implements Filter {
@Override
public void destroy() {}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterchain)
throws IOException, ServletException {
System.out.println("Remote Host:"+request.getRemoteHost());
System.out.println("Remote Address:"+request.getRemoteAddr());
filterchain.doFilter(request, response);
}
@Override
public void init(FilterConfig filterconfig) throws ServletException {}
}
FilterChain:
A FilterChain is an object provided by the servlet container to the developer giving a view into the invocation chain of a filtered request for a resource. Filters use the FilterChain to invoke the next filter in the chain, or if the calling filter is the last filter in the chain, to invoke the resource at the end of the chain.
Causes the next filter in the chain to be invoked, or if the calling filter is the last filter in the chain, causes the resource at the end of the chain to be invoked.
Params:
request – the request to pass along the chain.
response – the response to pass along the chain.
Throws:
IOException – if an I/O error occurs during the processing of the request
ServletException – if the processing fails for any other reason
ما را در سایت هم میهنان کورد زبانم تسلیت... دنبال میکنید
برچسب: نویسنده: بازدید: 106