• 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 HttpServletRequest and It’s Methods?
Next →
← Prev

What is HttpServletRequest and It’s Methods?

By Dinesh Thakur

HttpServletRequest is an interface and extends the ServletRequest interface. By extending the ServletRequest this interface is able to allow request information for HTTP Servlets. Object of the HttpServletRequest is created by the Servlet container and, then, it is passed to the service method (doGet(), doPost(), etc.) of the Servlet.

Extends the ServletRequest interface to provide request information for HTTP servlets.

The servlet container creates an HttpServletRequest object and passes it as an argument to the servlet’s service methods (doGet, doPost, etc.).

i. public String getAuthType()

Returns the name of the authentication scheme used to protect the servlet.

ii. public String getContextPath ()

Returns the portion of the request URI that indicates the context of the request.

iii. public Cookie [] getCookies ( )

Returns an array containing all of the cookie objects the client sent with this request.

iv public long getDateHeader(String name)

Returns the value of the specified request header as a long value that represents a date object.

v public String getHeader(String name)

Returns the value of the specified request header as a string.

vi. public Enumeration getHeaderNames()

Returns an enumeration of all the header names this request contains.

vii. public Enumeration getHeaders (String name)

Returns all the values of the specified request header as an enumeration of String objects.

viii. public int getIntHeader (String name)

Returns the value of the specified request header as an int.

ix. public String getMethod()

Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT, same as the value of the CGI variable REQUEST_METHOD.

x. public String getPathlnfo()

Returns any extra path information associated with the URL the client sent when it made this request.

xi. public String getpathTranslated ()

Returns any extra path information after the servlet name but before the query string, and translates it to a real path.

xii. public String getQueryString ()

Returns the query string that is contained in the request URL after the path.

xiii. public String getRemoteUser ()

Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.

xiv public String getRequestedSessionld()

Returns the session ID specified by the client.

xv public String getRequestURI()

Returns the part of this request’s URL from the protocol name up to the query string in the first line of the HTTP request.

xvi. public StringBuffer getRequestURL()

Reconstructs the URL the client used to make the request.

xvii.public String getServletpath ()

Returns the part of this request’s URL that calls the serv let.

xviii.public HttpSession getSession ()

Returns the current session associated with this request, or if the request does not have a session, creates one.

xix. public HttpSession getSession(boolean create)

Returns the current HttpSession associated with this request or, if there is no current session and create is true, returns a new session.

xx. public Principal getUserPrincipal()

Returns a java.security. Principal object containing the name of the current authenticated user.

xxi. public boolean isRequestedSessionldFromCookie()

Checks whether the requested session ID came in as a cookie.

xxii. public boolean isRequestedSessionldValid()

Checks whether the requested session ID is still valid.

xxiii. public boolean isUserlnRole (String role)

Returns a boolean indicating whether the authenticated user is included in the specified logical role.

You’ll also like:

  1. What is HttpServletResponse 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