Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 20th, 2007, 05:12 PM
Registered User
 
Join Date: Sep 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with HTTP Headers in servlet vs ASP

Hi,

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 %>
      <TR>
           <TD>
                <%= name %>
           </TD>
           <TD>
                <%= Request.ServerVariables(name) %>
           </TD>
      </TR>
      <% Next %>

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

HTTP_ACCEPT */*
HTTP_ACCEPT_LANGUAGE en-us
HTTP_CONNECTION Keep-Alive
HTTP_HOST idcqa08
HTTP_USER_AGENT Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)
HTTP_COOKIE 8qtUErqeJcKC0FqGJEo=;
HTTP_UA_CPU x86
HTTP_ACCEPT_ENCODING gzip, deflate

HTTP_SM_TRANSACTIONID
HTTP_SM_REALM
HTTP_SM_REALMOID
HTTP_SM_SDOMAIN
HTTP_SM_AUTHTYPE
HTTP_USERFIRSTNAME

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:*/*
accept-language:en-us
ua-cpu:x86
accept-encoding:gzip, deflate
user-agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)
host:idcqa04.nthorbit.com:8888
connection:Keep-Alive
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?

thx
Amar
Reply With Quote
  #2 (permalink)  
Old October 1st, 2007, 11:50 PM
Registered User
 
Join Date: Oct 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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:
Code:
<TABLE BORDER=1>
<TR>
  <TH>Variable</TH>
  <TH>Value</TH>
</TR>
<% For Each strVarName in Request.ServerVariables %>
    <TR>
    <TD><%=strVarName%></TD>
    <TD>
    <%
    If Len(Request.ServerVariables(strVarName)) = 0 Then
        Response.Write GetAttribute(strVarName) 
    Else        
        Response.Write Request.ServerVariables(strVarName)
    End If
    Response.Write "&nbsp;</TD>"
    %>
    </TR>
<% Next %>
</TABLE>

<% 
   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.
Reply With Quote
  #3 (permalink)  
Old October 20th, 2011, 04:43 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Sudhir
Reply With Quote
  #4 (permalink)  
Old November 15th, 2011, 03:47 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 .......
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:31 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.