You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by wicket user <sa...@live.com> on 2012/08/13 18:02:19 UTC

how to get HttpServletRequest in My Application class

Hi,

I need to get the HttpServletRequest  object in My Application class. In the
WebPage we can get from 

((HttpServletRequest) ((ServletWebRequest)
getRequest()).getContainerRequest())

but its not working in Application class. Please suggest any ideas. 



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/how-to-get-HttpServletRequest-in-My-Application-class-tp4651189.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: how to get HttpServletRequest in My Application class

Posted by Joachim Schrod <js...@acm.org>.
wicket user wrote:
> 
> I need to get the HttpServletRequest  object in My Application class. In the
> WebPage we can get from 
> 
> ((HttpServletRequest) ((ServletWebRequest)
> getRequest()).getContainerRequest())
> 
> but its not working in Application class.

I'm new to Wicket, but it seems obvious that this is impossible.

The application object exists outside of resp. independent of any
servlet requests. Only Web pages and their components are
concercened with HTTP requests, and thus only they have access.

If you want to store or access something from a request in your
application object -- which is a singleton that's independent from
any request and any session, then there's probably something wrong
with your design.

	Joachim

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Joachim Schrod, Roedermark, Germany
Email: jschrod@acm.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: how to get HttpServletRequest in My Application class

Posted by Paul Bors <pa...@bors.ws>.
BTW, if you get a NPE on RequestCycle.get() then you most likely place this
code outside a Wicket Component like a Page.

Try moving it to a page first and see if you grab a reference to the request
object. If you do, then pass it as a parameter to your other method/class.

For older version of Wicket < 1.5.x see:
https://cwiki.apache.org/WICKET/request-cycle-and-request-cycle-processor.ht
ml

For newer version see:
https://cwiki.apache.org/WICKET/requestcycle-in-wicket-15.html

~ Thank you,
  Paul Bors

-----Original Message-----
From: Paul Bors [mailto:paul@bors.ws] 
Sent: Monday, August 13, 2012 1:18 PM
To: users@wicket.apache.org
Subject: RE: how to get HttpServletRequest in My Application class

For your reference also see:
https://cwiki.apache.org/WICKET/getting-a-url-for-display.html

~ Thank you,
  Paul Bors

-----Original Message-----
From: wicket user [mailto:samdani@live.com] 
Sent: Monday, August 13, 2012 1:07 PM
To: users@wicket.apache.org
Subject: Re: how to get HttpServletRequest in My Application class

I am getting java.lang.NullPointerException
((ServletWebRequest)RequestCycle.get().getRequest()).getContainerRequest() 
.  




--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/how-to-get-HttpServletRequest-in-
My-Application-class-tp4651189p4651196.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: how to get HttpServletRequest in My Application class

Posted by Paul Bors <pa...@bors.ws>.
For your reference also see:
https://cwiki.apache.org/WICKET/getting-a-url-for-display.html

~ Thank you,
  Paul Bors

-----Original Message-----
From: wicket user [mailto:samdani@live.com] 
Sent: Monday, August 13, 2012 1:07 PM
To: users@wicket.apache.org
Subject: Re: how to get HttpServletRequest in My Application class

I am getting java.lang.NullPointerException
((ServletWebRequest)RequestCycle.get().getRequest()).getContainerRequest() 
.  




--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/how-to-get-HttpServletRequest-in-
My-Application-class-tp4651189p4651196.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: how to get HttpServletRequest in My Application class

Posted by wicket user <sa...@live.com>.
I am getting java.lang.NullPointerException
((ServletWebRequest)RequestCycle.get().getRequest()).getContainerRequest() 
.  




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/how-to-get-HttpServletRequest-in-My-Application-class-tp4651189p4651196.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: how to get HttpServletRequest in My Application class

Posted by Andrea Del Bene <an...@gmail.com>.
Try this:

((ServletWebRequest)RequestCycle.get().getRequest()).getContainerRequest()
> Hi,
>
> I need to get the HttpServletRequest  object in My Application class. In the
> WebPage we can get from
>
> ((HttpServletRequest) ((ServletWebRequest)
> getRequest()).getContainerRequest())
>
> but its not working in Application class. Please suggest any ideas.
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/how-to-get-HttpServletRequest-in-My-Application-class-tp4651189.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>