• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » Servlet » Examples » What is HttpServletResponse and It’s Methods?
Next →
← Prev

What is HttpServletResponse and It’s Methods?

By Dinesh Thakur

HttpServletResponse is a predefined interface present in javax.servlet.http package. It can be said that it is a mirror image of request object. The response object is where the servlet can write information about the data it will send back. Whereas the majority of the methods in the request object start with GET, indicating that they get a value, many of the important methods in the response object start with SET, indicating that they change some property. Note that these interfaces adhere to the usual naming conventions for beans.

Methods in HttpServletResponse

i. public void addCookie(Cookie cookie)

Adds the specified cookie to the response. This method can be called multiple times to set more than one cookie.

ii. public void addDateHeader (String name, long date)

Adds a response header with the given name and date-value.

iii. public void addHeader(String name,String value)

Adds a response header with the given name and value.

iv public void addlntHeader(String name,int value)

Adds a response header with the given name and integer value.

v public boolean containsHeader(String name)

Returns a boolean indicating whether the named response header has already been set.

vi. public String encodeRedirectURL(String url)

Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged.

vii. public String encodeURL(String url)

Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.

viii. public void sendError(int sc) throws IOException

Sends an error response to the client using the specified status code and clearing the buffer.

ix. public void sendError(int Be, String mag) throws IOException

Sends an error response to the client using the specified status clearing the buffer.

x. public void sendRedirect(string location) throws IOException

Sends a temporary redirect response to the client using the specified redirect location URL.

xi. public void setDateHeader(String name,long date)

Sets a response header with the given name and date-value.

xii. public void setHeader(String name, String value)

Sets a response header with the given name and value.

xiii. public void setlntHeader (String name,int value)

Sets a response header with the given name and integer value.

xiv public void setStatus(int sc)

Sets the status code for this response.

You’ll also like:

  1. What is HttpServletRequest and It’s Methods?
  2. What is Formal Methods Model? Advantages and Disadvantages of Formal Methods Model
  3. What is HttpServlet and it’s Methods?
  4. How many amplitude levels are there for each of the following methods
  5. What is Methods in Java ? – Definition (With Examples)
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

Servlet Tutorials

Servlet Tutorials

  • Servlet - Home
  • Servlet - Types
  • Servlet - Advantages
  • Servlet - Container
  • Servlet - API
  • Servlet - Chaining
  • Servlet - Life Cycle
  • Servlet - Developement Way
  • Servlet - Servlet Vs CGI
  • Servlet - Server Side
  • Servlet - HttpServletRequest
  • Servlet - Cookies Advantages
  • Servlet - JDBC Architecture
  • Servlet - HttpServlet
  • Servlet - HttpServletResponse
  • Servlet - Web Technology
  • Servlet - Applet Communication
  • Servlet - Html Communication
  • Servlet - HTTP POST Request
  • Servlet - HTTP GET Request

Other Links

  • Servlet - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW