users@glassfish.java.net

Re: JAX RS / HttpRequest Object?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 16 Feb 2010 22:20:28 +0100

On Feb 16, 2010, at 9:09 PM, glassfish_at_javadesktop.org wrote:

> While I'm not sure if it's possible to get the httpServletRequest
> object back,

It is possible, do:

@Context HttpServletRequest hsr;

Paul.

> it does appear to be possible to get a variety of other pieces of
> information back.
>
>
> [code]
> @Context
> private SecurityContext ctx;
>
> @GET
> @Produces("text/plain")
> public String getUserPrincipal() {
> return ctx.getUserPrincipal.getName();
> }
> [/code]
>
> Relevant Forum:
> http://www.coderanch.com/t/422684/Web-Services/java/Accessing-HttpServletRequest-from-Restful-webservice
> [Message sent by forum member 'hoffman462' (HoffmanDanielG_at_gmail.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=387053
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>