Getting a Request Header in a JSP Page - Java Servlet JSP

Java examples for Servlet JSP:JSP

Introduction

The request method is

<%= request.getMethod() %>

The request URI is

<%= request.getRequestURI() %>

The request protocol is

<%= request.getProtocol() %>

The browser is

<%= request.getHeader("user-agent") %>
<%
    java.util.Enumeration names = request.getHeaderNames();
    while (names.hasMoreElements()) {
        String name = (String)names.nextElement();
        out.println(name+": "+request.getHeader(name));
    }
%>

Related Tutorials