jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willie H Armstrong <warms...@csc.com>
Subject Problem with referer header.
Date Wed, 11 May 2005 14:34:53 GMT





I am having a problem with the Referer header being "distorted" by the
WebRequest.addHeader() method.  The header name and the header value
gets changed into: "~~~~~~~" and "~~~~:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
which I see when examining the Enumeration en in the debugger.

I am attempting to set two headers in a WebRequest.

code pieces as follows:


// the imports
import org.apache.cactus.ServletTestCase;
import org.apache.cactus.WebResponse;
import org.apache.cactus.WebRequest;

// "setting up" the request
    public void beginProcessRequestNotReseeding(WebRequest request) {
        System.out.print("beginProcessRequestNotReseeding");
        request.addHeader("HTTP_SM_USER", strHttpUser);
        request.addHeader("Referer", strRefUrl);
        System.out.println(".....Completed client side begin.");
    }
....
// sending the request

   public void testProcessRequestNotReseeding() {
        System.out.println("testProcessRequestNotReseeding");
        assertFalse("Credential was set to true",
Credentialer.isReseeding());
        Enumeration en = request.getHeaderNames();
        try {
            servlet.processRequest(request, response);
        } catch (javax.servlet.ServletException jsse) {
            // do nothing
        } catch (IOException jioe) {
            // do nothing
        }
        Credentialer.setReseeding(false);
        System.out.println(".....Completed.");
    }

// adding a Basic Authentication to  header then dispatching it to
Sender servlet

.... called by testProcessRequestNotReseeding() ........

    protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
    throws ServletException, IOException {
.......
            String strUser = request.getHeader("HTTP_SM_USER");
            String strPW = Credentialer.getPassword(strUser);
            // put BasicAuthurization data in request header
            try {
                response.setHeader("Authorization", "Basic " +
makeAuthedString(strUser, strPW));
            } catch (EncoderException acnee){
                acnee.printStackTrace();
                // TODO make an HTML Message of failure);
            }
            // send request to Refer url
            request.getRequestDispatcher("/Sender").forward(request,
response);
    }


// the Sender servlet does redirect to back to the referer.
... the final servlet method called

    protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
    throws ServletException, IOException {
      String strRefURL = request.getHeader("Referer");
      response.sendRedirect(strRefURL);
    }


The String strRefUrl is set to null so the sendRedirect of course fails.

I have checked the W3C HTTP docs and it appears the the Referer name and
value are both Strings.


Any assistance is appreciated.

Best Regards,
Bill





Willie (Bill) Armstrong
Sun Certified Programmer for the Java 2 Platform 1.4


Mime
View raw message