Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 20th, 2007, 05:12 PM
Registered User
Join Date: Sep 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with HTTP Headers in servlet vs ASP


I am trying to read custom http header variables in our servlet application but it does not seem to work.

We are using siteminder with it's web agent so it is configured to pass custom siteminder variables back through the webagent as HTTP header variables.

So we go the webagent login page and upon successful authenication it gets the custom user profile settings and sets them as http header variables in the response. The webagent then redirects to another url passing those custom http headers along.

So when I redirect the webagent to an ASP page using this test ASP code under IIS

      <% For Each name In Request.ServerVariables %>
                <%= name %>
                <%= Request.ServerVariables(name) %>
      <% Next %>

I get the basic standard headers along with our custom ones such as

HTTP_HOST idcqa08
HTTP_USER_AGENT Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)


However when I have that same webagent rediect to a JSP page running the following code under Tomcat (similar code was run as a servlet as well under weblogic)


public String headers(HttpServletRequest request)
    java.util.Enumeration headerNames = request.getHeaderNames();
    String requestHeaders = "";
    String currentHeader;
    while (headerNames.hasMoreElements())
        currentHeader = (String) headerNames.nextElement();
        requestHeaders += currentHeader + ":" + request.getHeader(currentHeader) + " <br> ";

    return requestHeaders;


<%= headers(request) %>

I only get the basic standard headers and no custom ones at all

accept-encoding:gzip, deflate
user-agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)
cookie:SMSESSION=TDnqdwa9B+tBjNeseE8mTPN4dCXBP14n3 4V/u5+rAQSU5fm/=;

I can't seem to figure out why and I really need to get this to work with our java servlet application which is running under weblogic 8.1

Any ideas?

Old October 1st, 2007, 11:50 PM
Registered User
Join Date: Oct 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Although you seem pretty happy with the way it is working in IIS, it might be worth noting that SiteMinder may return the headers in the "ALL_HTTP" variable rather than as separate header variables. To ensure these values are also shown in your debug page, you might like to update the debug code to something like:
<% For Each strVarName in Request.ServerVariables %>
    If Len(Request.ServerVariables(strVarName)) = 0 Then
        Response.Write GetAttribute(strVarName) 
        Response.Write Request.ServerVariables(strVarName)
    End If
    Response.Write "&nbsp;</TD>"
<% Next %>

   Function GetAttribute(AttrName)
        Dim AllAttrs
        Dim RealAttrName
        Dim Location
        Dim Result

        AllAttrs = Request.ServerVariables("ALL_HTTP")
        RealAttrName = AttrName

        Location = InStr(AllAttrs, RealAttrName & ":")

        If Location <= 0 Then
            GetAttribute = ""
            Exit Function
        End If

        Result = Mid(AllAttrs, Location + Len(RealAttrName) + 1)

        Location = InStr(Result, Chr(10))
        If Location <= 0 Then Location = Len(Result) + 1

        GetAttribute = Left(Result, Location - 1)
    End Function 
Regarding the missing headers when using JSP, it might be worth checking that your SiteMinder ISAPI filter is higher in the list than the Tomcat/WebLogic filter. Apart from that, there may be a setting in Tomcat/Weblogic that is removing the header variables or preventing them from being passed through.
Old October 20th, 2011, 04:43 AM
Registered User
Join Date: Oct 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Hello Amer,

Are you able to resolve your issue. I am also facing the same issue. If resolved please let me know.

thanks in advance.

Old November 15th, 2011, 03:47 AM
Registered User
Join Date: Nov 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Hi ....I am also facing the exactly same issue . I am not getting any solution since last 4 days.Can you please provide solution is its resolved.

Thanks in Advance

Rahul .......

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access underlying HTTP headers in web service. glen205 .NET Web Services 0 November 27th, 2006 07:36 PM
WHat is "http headers"? gilgalbiblewheel Classic ASP Databases 1 September 14th, 2005 11:59 AM
http headers in asp ocabrera70 Classic ASP Basics 2 April 26th, 2005 08:39 AM
Servlet & HTTP Parsing lian_a Servlets 0 April 30th, 2004 01:57 AM
Tomcat HTTP Headers pcroadkill Apache Tomcat 1 April 10th, 2004 06:11 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.