Standalone Search Box Example

Spanish syndication test when the translation enabled

Spanish syndication test when the translation enabled

This is new sample demo component test
n
XCommAdmin
Trusted Contributor

Spanish syndication test when the translation enabled

Spanish syndication test when the translation enabled

 

ServletResponse interface is used by servlet in sending response to the client. Servlet container creates the ServletResponse object and pass it to servlet service() method and later use the response object to generate the HTML response for client.

Some of the important methods in HttpServletResponse are:

  1. void addCookie(Cookie cookie) – Used to add cookie to the response.
  2. void addHeader(String name, String value) – used to add a response header with the given name and value.
  3. String encodeURL(java.lang.String url) – encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.
  4. String getHeader(String name) – return the value for the specified header, or null if this header has not been set.
  5. void sendRedirect(String location) – used to send a temporary redirect response to the client using the specified redirect location URL.
  6. void setStatus(int sc) – used to set the status code for the response.

 

 

3 REPLIES 3
XCommAdmin
Trusted Contributor

Servlet technology is used to create a web application (resides at server side and generates a dynamic web page).

Servlet technology is robust and scalable because of java language. Before Servlet, CGI (Common Gateway Interface) scripting language was common as a server-side programming language. However, there were many disadvantages to this technology. We have discussed these disadvantages below.

There are many interfaces and classes in the Servlet API such as Servlet, GenericServlet, HttpServlet, ServletRequest, ServletResponse, etc.

 

  • Servlets provide better performance that CGI in terms of processing time, memory utilization because servlets uses benefits of multithreading and for each request a new thread is created, that is faster than loading creating new Object for each request with CGI.

 

javax.servlet.Servlet is the base interface of Servlet API. There are some other interfaces and classes that we should be aware of when working with Servlets. Also with Servlet 3.0 specs, servlet API introduced the use of annotations rather than having all the servlet configuration in the deployment descriptor. In this section, we will look into important Servlet API interfaces, classes and annotations that we will use further in developing our application. The below diagram shows servlet API hierarchy.