You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Masataka Kurihara <ku...@gluegent.com> on 2004/01/14 03:52:30 UTC

RequestContext#getHeader(String)

Hellow,

 I want org.apache.tapestry.request.RequestContext
#getHeader(String):String, #getHeaders(String):Enumeration
and getHeaderNames():Enumeration. 


 I am switching my own company's web site from Cocoon2
to Tapestry3 now.
This web site will be for Windows users, *nix users
and Mac users. So site design is adjusted by using multiple
css.
 I think that selecting css needs HTTP request header
"User-Agent". I am coding follow in page object because
org.apache.tapestry.request.RequestContext has not 
how to get request-headers directly.
--
import javax.servlet.http.HttpRequest; //<-- Wmmm.
public IAsset getStylesheet() {
  HttpRequest req = getPage().getRequestCycle()
    .getRequestContext().getRequest();
  String agent = req.getHeader("User-Agent");
  ......
}
--
 Tapestry wraps all other useful Servlet API and Spindle
make default project which has not servlet*.jar. I think that
RequestContext must have getter methods for request-header.
(#setHeader(String, String) and #addHeader(String, String)
needs???)

Thanks,
Masataka Kurihara


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


RE: RequestContext#getHeader(String)

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
If I was starting from scratch, I would remove most of the methods, including getParameter(), from
RequestContext.  However, that would cause a lot of code changes, break a lot of components.  So I
will do nothing.

--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Tapestry: Java Web Components 
http://jakarta.apache.org/tapestry/
http://javatapestry.blogspot.com

> -----Original Message-----
> From: Masataka Kurihara [mailto:kurihara@gluegent.com] 
> Sent: Wednesday, January 14, 2004 7:56 PM
> To: Tapestry development
> Subject: Re: RequestContext#getHeader(String)
> 
> 
> Thanks for your replying,
> 
>   I see, ofcource we can get HttpServletRequest object from
> RequestContext and I seem too, Tapestry's APIs will grow
> up.
> 
> > no need to extend the interface for RequestContext itself.
>                                                      ~~~~~~
> Please tell me "itself" means(sorry, I'm not native English
> speaker, I can't understand your easy word means). Will you
> delete getParameter*(*) methods from RequestContext? Or will
> you move getParameter*(*) and create getHeader*(*) methods 
> in IRequestCycle? or do nothing in this matter?
> 
> Regards,
> Masataka Kurihara
> 
> > The origional idea behind RequestContext was to bundle up 
> HttpServletRequest, HttpServletResponse
> > and HttpSession together so that we could pass a single 
> facade object around as a parameter, rather
> > than all three. As Tapestry grew, IRequestCycle ended up 
> wrapping around RequestContext. Because the
> > facade is transparent (you can get from IRequestCycle to 
> RequestContext to HttpServletRequest)
> > there's no need to extend the interface for RequestContext itself.
> > 
> > The best APIs are the leanest, and Tapestry is (to my mind) 
> a little too fat (reflecting my growing
> > experience in Java over the last four years).
> > 
> > --
> > Howard M. Lewis Ship
> > Independent J2EE / Open-Source Java Consultant
> > Creator, Tapestry: Java Web Components 
> > http://jakarta.apache.org/tapestry/
> > http://javatapestry.blogspot.com
> > 
> > > -----Original Message-----
> > > From: Masataka Kurihara [mailto:kurihara@gluegent.com] 
> > > Sent: Tuesday, January 13, 2004 9:53 PM
> > > To: tapestry-dev@jakarta.apache.org
> > > Subject: RequestContext#getHeader(String)
> > > 
> > > 
> > > Hellow,
> > > 
> > >  I want org.apache.tapestry.request.RequestContext
> > > #getHeader(String):String, #getHeaders(String):Enumeration
> > > and getHeaderNames():Enumeration. 
> > > 
> > > 
> > >  I am switching my own company's web site from Cocoon2
> > > to Tapestry3 now.
> > > This web site will be for Windows users, *nix users
> > > and Mac users. So site design is adjusted by using multiple
> > > css.
> > >  I think that selecting css needs HTTP request header
> > > "User-Agent". I am coding follow in page object because
> > > org.apache.tapestry.request.RequestContext has not 
> > > how to get request-headers directly.
> > > --
> > > import javax.servlet.http.HttpRequest; //<-- Wmmm.
> > > public IAsset getStylesheet() {
> > >   HttpRequest req = getPage().getRequestCycle()
> > >     .getRequestContext().getRequest();
> > >   String agent = req.getHeader("User-Agent");
> > >   ......
> > > }
> > > --
> > >  Tapestry wraps all other useful Servlet API and Spindle
> > > make default project which has not servlet*.jar. I think that
> > > RequestContext must have getter methods for request-header.
> > > (#setHeader(String, String) and #addHeader(String, String)
> > > needs???)
> > > 
> > > Thanks,
> > > Masataka Kurihara
> > > 
> > > 
> > > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: 
> tapestry-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: 
> tapestry-dev-help@jakarta.apache.org
> > > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: 
> tapestry-dev-help@jakarta.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


Re: RequestContext#getHeader(String)

Posted by Masataka Kurihara <ku...@gluegent.com>.
Thanks for your replying,

  I see, ofcource we can get HttpServletRequest object from
RequestContext and I seem too, Tapestry's APIs will grow
up.

> no need to extend the interface for RequestContext itself.
                                                     ~~~~~~
Please tell me "itself" means(sorry, I'm not native English
speaker, I can't understand your easy word means). Will you
delete getParameter*(*) methods from RequestContext? Or will
you move getParameter*(*) and create getHeader*(*) methods 
in IRequestCycle? or do nothing in this matter?

Regards,
Masataka Kurihara

> The origional idea behind RequestContext was to bundle up HttpServletRequest, HttpServletResponse
> and HttpSession together so that we could pass a single facade object around as a parameter, rather
> than all three. As Tapestry grew, IRequestCycle ended up wrapping around RequestContext. Because the
> facade is transparent (you can get from IRequestCycle to RequestContext to HttpServletRequest)
> there's no need to extend the interface for RequestContext itself.
> 
> The best APIs are the leanest, and Tapestry is (to my mind) a little too fat (reflecting my growing
> experience in Java over the last four years).
> 
> --
> Howard M. Lewis Ship
> Independent J2EE / Open-Source Java Consultant
> Creator, Tapestry: Java Web Components 
> http://jakarta.apache.org/tapestry/
> http://javatapestry.blogspot.com
> 
> > -----Original Message-----
> > From: Masataka Kurihara [mailto:kurihara@gluegent.com] 
> > Sent: Tuesday, January 13, 2004 9:53 PM
> > To: tapestry-dev@jakarta.apache.org
> > Subject: RequestContext#getHeader(String)
> > 
> > 
> > Hellow,
> > 
> >  I want org.apache.tapestry.request.RequestContext
> > #getHeader(String):String, #getHeaders(String):Enumeration
> > and getHeaderNames():Enumeration. 
> > 
> > 
> >  I am switching my own company's web site from Cocoon2
> > to Tapestry3 now.
> > This web site will be for Windows users, *nix users
> > and Mac users. So site design is adjusted by using multiple
> > css.
> >  I think that selecting css needs HTTP request header
> > "User-Agent". I am coding follow in page object because
> > org.apache.tapestry.request.RequestContext has not 
> > how to get request-headers directly.
> > --
> > import javax.servlet.http.HttpRequest; //<-- Wmmm.
> > public IAsset getStylesheet() {
> >   HttpRequest req = getPage().getRequestCycle()
> >     .getRequestContext().getRequest();
> >   String agent = req.getHeader("User-Agent");
> >   ......
> > }
> > --
> >  Tapestry wraps all other useful Servlet API and Spindle
> > make default project which has not servlet*.jar. I think that
> > RequestContext must have getter methods for request-header.
> > (#setHeader(String, String) and #addHeader(String, String)
> > needs???)
> > 
> > Thanks,
> > Masataka Kurihara
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


RE: RequestContext#getHeader(String)

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
The origional idea behind RequestContext was to bundle up HttpServletRequest, HttpServletResponse
and HttpSession together so that we could pass a single facade object around as a parameter, rather
than all three. As Tapestry grew, IRequestCycle ended up wrapping around RequestContext. Because the
facade is transparent (you can get from IRequestCycle to RequestContext to HttpServletRequest)
there's no need to extend the interface for RequestContext itself.

The best APIs are the leanest, and Tapestry is (to my mind) a little too fat (reflecting my growing
experience in Java over the last four years).

--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Tapestry: Java Web Components 
http://jakarta.apache.org/tapestry/
http://javatapestry.blogspot.com

> -----Original Message-----
> From: Masataka Kurihara [mailto:kurihara@gluegent.com] 
> Sent: Tuesday, January 13, 2004 9:53 PM
> To: tapestry-dev@jakarta.apache.org
> Subject: RequestContext#getHeader(String)
> 
> 
> Hellow,
> 
>  I want org.apache.tapestry.request.RequestContext
> #getHeader(String):String, #getHeaders(String):Enumeration
> and getHeaderNames():Enumeration. 
> 
> 
>  I am switching my own company's web site from Cocoon2
> to Tapestry3 now.
> This web site will be for Windows users, *nix users
> and Mac users. So site design is adjusted by using multiple
> css.
>  I think that selecting css needs HTTP request header
> "User-Agent". I am coding follow in page object because
> org.apache.tapestry.request.RequestContext has not 
> how to get request-headers directly.
> --
> import javax.servlet.http.HttpRequest; //<-- Wmmm.
> public IAsset getStylesheet() {
>   HttpRequest req = getPage().getRequestCycle()
>     .getRequestContext().getRequest();
>   String agent = req.getHeader("User-Agent");
>   ......
> }
> --
>  Tapestry wraps all other useful Servlet API and Spindle
> make default project which has not servlet*.jar. I think that
> RequestContext must have getter methods for request-header.
> (#setHeader(String, String) and #addHeader(String, String)
> needs???)
> 
> Thanks,
> Masataka Kurihara
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org