"Chen, Gin" wrote:
> I'm not exactly sure how this should be handled. I have a page
> that looks up a value that is passed to it through header
> information. So I'm doing a request.getHeader("blah");
>
> This is working fine until I try to make a false intro
> page that leads to that page. In my false page I do a
> response.setHeader("blah" "myvalueforblah"); and then do a
> request.getRequestDispatcher("mypage").forward( request,
> response ); But I cant pick up that header blah.
>
> What am I doing wrong? How do I send header information
> to another page? Anyone have an example of using the headers to
> pass application specific values?
In this instance, as was happening in other the message you posted,
you're writing a response header and reading a request header, so it
makes sense that you won't find the header data.
Thoughts in no particular order:
I'd lean toward modifying the page that needs to read the header to try
the header first, then fall back on a request attribute which your intro
page can set.
The request headers should be coming from the client, so why is the
header you need present in the direct request to the page but not
present in the request to the intro page? Can you get the client to send
the header you need when requesting the intro page?
If you're using Servlet 2.3, you might look into using a request
wrapper. I'm thinking of something like the following, though this is
being written without reference to the spec/API, so the syntax is
doubtless off.
class HeaderModRequest extends HttpServletRequestWrapper
{
void setHeader(String header, String value)
{
// store the header in local table
}
String getHeader(String header)
{
// look in local header table; if not found,
// delegate to super()
}
}
HeaderModRequest wrapper = new HeaderModRequest(request);
wrapper.setHeader("blah", "value");
request.getRequestDispatcher("mypage").forward(wrapper,
response);
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html