• 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 » How to gather miscellaneous information from HttpRequest
Next →
← Prev

How to gather miscellaneous information from HttpRequest

By Dinesh Thakur

We can gather the miscellaneous information from HttpRequest by calling various getxxx methods on request object as shown below.

* Use user-agent request header that holds browser software name as shown below.

  In service (–) method

 PW.println (“<br> <br> the current browser window” +req.getHeader (“user-agent”) )// request header name.

* The URL pattern of servlet program is technically called as servlet path.

   //example request URL: https://ecomputernotes.com:2020/FolderName/PName? sno=11

PW.println (“<br> miscellaneous information of http request”);

//methods available in javax.Servlet.ServletRequest

PW.println (“<br> Request Content Length:” +req.getContentLength ());
 //gives request data length in bytes like 345 bytes (if not known gives -1)
PW.println (“<br> request content type:” +req.getContentType ());
 //gives request content like text/html (if not known gives null)
PW.println (“<br> request protocol:” +req.getProtocol ());
 //gives http/1.1
PW.println (“<br> request scheme:” +req.getScheme ());
 //gives Http
PW.println (“<br> request browser window machine IP address:” +req.getRemoteAddr ());
//gives 127.0.0.1
PW.println (“<br> browser window machine host name:” +req.getRemoteHost ());
//gives current computer name otherwise IP address
PW.println (“<br> browser window port no:” +req.getRemotePort ());
//gives 2922 for Netscape, 2926 for IE
PW.println (“<br> server name” +req.getServerName ());
//gives the domain name typed in the url like local host
PW.println (“<br> server port” +req.getServerPort ());
//gives 2020
//methods available in javax.Servlet.HttpServletRequest
PW.println (“<br> context path:” +req.getContextPath ());
//gives FolderName
PW.println (“<br> request method is:” +req.getMethod ());
//gives GET
PW.println (“<br> request path info is:” +req.getPathInfo ());
//gives additional information kept in request url (otherwise null)
PW.println (“<br> query string is:” +req.getQueryString ());
//gives sno = 11
PW.println (“<br> request uri:” +req.getRequestURI ());
//gives /FolderName/PName
PW.println (“<br> request url:” +req.getRequestURL ());
//gives https://ecomputernotes.com:2020/ FolderName/PName
PW.println (“<br> servlet path:” +req.getServletPath ());
//gives /PName

* Servlet program can avoid browser dependent tags while generating html tags based response if by knowing browser software name through the request header user-agent.

When web resource program (like servlet program) sends response to browser window the generated http response contain multiple details including response content. Those details can be remembered as SCH details.

You’ll also like:

  1. What is Information Technology? Explain Difference Between Data and Information
  2. Business Value of Information in Management Information Systems
  3. what is the difference between information systems and information technology
  4. What do you understand by Information? What are the Characteristics of Information
  5. Value of Information in Management Information System
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