You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Altuğ B. Altıntaş" <al...@gmail.com> on 2009/07/14 12:47:16 UTC

Re: how to get some data from servlet

Also I have a problem like yours.

Servlet session and Wicket's session are different so you are getting nul.
Just debug your application and you will see that they have different
session Id's.

I tried to use WicketSessionFilter but it doesn't work.

I am using wicket 1.3.5.

Cheers...

Altug.

2009/6/23 danisevsky <da...@gmail.com>

> hello, I am using MyMultiFileUploadServlet for uploading files and in some
> wicket component I need find out how many files was uploaded.
> I was trying to set this number to the HttpSession in
> MyMultiFileUploadServlet and get it in the component:
>
>                    HttpSession httpSession = ((WebRequest)
> getRequest()).getHttpServletRequest()
>                            .getSession();
> String count = httpSession
>                            .getAttribute("filesCount");
>
> but count is always null. Is there any way how to get some data from
> servlet? Thanks
>



-- 
Altuğ.

Re: how to get some data from servlet

Posted by Zilvinas Vilutis <ci...@gmail.com>.
SecureSessionHolder: http://pastebin.com/J891bDye

SecureSessionListener: http://pastebin.com/UBnLRLJ7

and just inside your implementation of
org.apache.wicket.authentication.AuthenticatedWebSession.authenticate(String,
String) ( or any other auth method ) call
SecureSessionHolder.addSecureSession( sessionId );



Žilvinas Vilutis

Mobile:   (+370) 652 38353
E-mail:   cikasfm@gmail.com


On Sun, May 9, 2010 at 6:57 PM, Fernando Wermus
<fe...@gmail.com>wrote:

> would you paste your code here? I will get a try if there is no problem.
>
> On Sat, May 8, 2010 at 9:04 PM, Zilvinas Vilutis <ci...@gmail.com>
> wrote:
>
> >
> > The problem is not in wicket, but in SwfUpload or more specific would be
> > the
> > Adobe Flash itself - which uses IE cookies in any case, even when you're
> > using FF or Chrome or Safari on Windows (
> > http://swfupload.org/forum/generaldiscussion/869 )
> >
> > Not sure how secure is it - but I've solved this in the following way:
> > - I've created a "SecureSessionHolder" static class which holds a list of
> > secure session ids
> > - Adding the secure session id to the list in "SecureSessionHolder" on
> > authentification
> > - an impl of "HttpSessionListener" to remove the session ids from the
> > static
> > list in "SecureSessionHolder" when session is destroyed
> > - in the SwfUpload servler just check if the session id ( passed as a
> > submit
> > parameter ) is in the secure session list in "SecureSessionHolder" before
> > parsing the response data
> >
> > If anybody has got any security concerns on this impl - please notify me,
> > I'll appreciate any opinions
> >
> > -----
> > --------------------
> > nothing is impossible
> > --
> > View this message in context:
> >
> http://apache-wicket.1842946.n4.nabble.com/how-to-get-some-data-from-servlet-tp1885531p2136546.html
> > Sent from the Wicket - User 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
> >
> >
>
>
> --
> Fernando Wermus.
>
> www.linkedin.com/in/fernandowermus
>

Re: how to get some data from servlet

Posted by Fernando Wermus <fe...@gmail.com>.
would you paste your code here? I will get a try if there is no problem.

On Sat, May 8, 2010 at 9:04 PM, Zilvinas Vilutis <ci...@gmail.com> wrote:

>
> The problem is not in wicket, but in SwfUpload or more specific would be
> the
> Adobe Flash itself - which uses IE cookies in any case, even when you're
> using FF or Chrome or Safari on Windows (
> http://swfupload.org/forum/generaldiscussion/869 )
>
> Not sure how secure is it - but I've solved this in the following way:
> - I've created a "SecureSessionHolder" static class which holds a list of
> secure session ids
> - Adding the secure session id to the list in "SecureSessionHolder" on
> authentification
> - an impl of "HttpSessionListener" to remove the session ids from the
> static
> list in "SecureSessionHolder" when session is destroyed
> - in the SwfUpload servler just check if the session id ( passed as a
> submit
> parameter ) is in the secure session list in "SecureSessionHolder" before
> parsing the response data
>
> If anybody has got any security concerns on this impl - please notify me,
> I'll appreciate any opinions
>
> -----
> --------------------
> nothing is impossible
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/how-to-get-some-data-from-servlet-tp1885531p2136546.html
> Sent from the Wicket - User 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
>
>


-- 
Fernando Wermus.

www.linkedin.com/in/fernandowermus

Re: how to get some data from servlet

Posted by Zilvinas Vilutis <ci...@gmail.com>.
The problem is not in wicket, but in SwfUpload or more specific would be the
Adobe Flash itself - which uses IE cookies in any case, even when you're
using FF or Chrome or Safari on Windows (
http://swfupload.org/forum/generaldiscussion/869 )

Not sure how secure is it - but I've solved this in the following way:
- I've created a "SecureSessionHolder" static class which holds a list of
secure session ids
- Adding the secure session id to the list in "SecureSessionHolder" on
authentification
- an impl of "HttpSessionListener" to remove the session ids from the static
list in "SecureSessionHolder" when session is destroyed
- in the SwfUpload servler just check if the session id ( passed as a submit
parameter ) is in the secure session list in "SecureSessionHolder" before
parsing the response data

If anybody has got any security concerns on this impl - please notify me,
I'll appreciate any opinions

-----
--------------------
nothing is impossible
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/how-to-get-some-data-from-servlet-tp1885531p2136546.html
Sent from the Wicket - User 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 some data from servlet

Posted by "Altuğ B. Altıntaş" <al...@gmail.com>.
I forgot to say : I am using Wicket 1.3.6 + Tomcat + java 6 ....  maybe it
gives a clue

2009/7/24 Altuğ B. Altıntaş <al...@gmail.com>

> I will post my codes. But now i catched a very very strange position in
> WicketSessionFilter .  Let me explain :
>
> I used WicketSessionFilter and a Simple UploadServlet as Igor said.
>
> I tested my application using Firefox 3. It gives :
>
> java.lang.IllegalStateException: you can only locate or create sessions in
> the context of a request cycle
>
> bla bla bla ...
>
> I tried to debug WicketSessionFilter , I can see that Filter runs and sets
> the Session into Thread but then My Servlet doesn't get the Session because
> some how WicketSessionFilter 's finally block runs and Session.unset()
> method executes.
>
> I think my Servlet can't catch the Session in Thread that
> WicketSessionFilter puts or something like that.
>
> The most strange part is : When I tested my application using Internet
> Explorer 8, WOOWs , It works. My Upload servlet can reach the same Session
> without any exception.  I think It means WicketSessionFilter and
> UploadServlet runs in proper order.
>
> Also I tested my application in Chrome, and I get the same exception :
>
> java.lang.IllegalStateException: you can only locate or create sessions in
> the context of a request cycle
>
> It likes  producer and consumer problem.
>
> Sessions in Wicket will kill me :)
>
> Also I set up Wicket examples and I can see WicketSessionFilter  runs
> properly.
>
> Any suggestions ?
>
> Thank you everybody.
>
> Altug.
>
>
> 2009/7/23 Fernando Wermus <fe...@gmail.com>
>
> Could you show to us the whole code? I mean, the page or panel that upload
>> the files as well the IRequestTarget class you have implemented?
>>
>> On Thu, Jul 23, 2009 at 10:31 AM, Altuğ B. Altıntaş <altuga@gmail.com
>> >wrote:
>>
>> > Hi all ;
>> >
>> > I can't use WicketSessionFilter maybe because I am using Apache Shiro
>> (old
>> > name is Apache Kİ).
>> >
>> > In fact Fernando's solution works; Now I can reach and use Session
>> inside
>> > UploadRequestTarget which implements IRequestTarget.
>> >
>> > But then I realized that I reach a different Session object in
>> > UploadRequestTarget class. It creates a new Session so i can  NOT access
>> it
>> > in other WebPages.
>> >
>> > In my Application class;
>> >
>> >  @Override
>> >    public final Session newSession(Request request, Response response)
>> > {
>> >            return new MySession(request);
>> >    }
>> >
>> > Are there any way to access all Sessions or stop creating a new Session
>> in
>> > UploadRequestTarget (which implements IRequestTarget)
>> >
>> > Thanks.
>> >
>> > Altug.
>> >
>> > 2009/7/20 Igor Vaynberg <ig...@gmail.com>
>> >
>> > > see WicketSessionFilter
>> > >
>> > > -igor
>> > >
>> > > On Sun, Jul 19, 2009 at 3:20 PM, Altuğ B. Altıntaş<al...@gmail.com>
>> > > wrote:
>> > > > Hi Igor;
>> > > >
>> > > > I found the problem; problem is when i hit my UploadServlet via
>> > http-get
>> > > > method , i simply write the url and hit the enter then below code is
>> > > working
>> > > >
>> > > >  Session wicketSession = Session.get();
>> > > >
>> > > > I can get wicket Session, wow !! it is great...
>> > > >
>> > > > BUT ...
>> > > >
>> > > > When i hit  my UploadServlet via http-post method, swfupload access
>> in
>> > > that
>> > > > way then i can NOT access wicketSession.
>> > > >
>> > > > I mean this code :
>> > > >
>> > > >  Session wicketSession = Session.get();
>> > > >
>> > > > it throws :
>> > > >
>> > > > java.lang.IllegalStateException: you can only locate or create
>> sessions
>> > > in
>> > > > the context of a request cycle
>> > > >
>> > > > Any idea ?
>> > > >
>> > > > Thanks
>> > > >
>> > > > Altug..
>> > > >
>> > > >
>> > > > 2009/7/14 Igor Vaynberg <ig...@gmail.com>
>> > > >
>> > > >> that doesnt make any sense. all things within the webapp share the
>> > > >> session. you guys are welcome to create a quickstart that
>> replicates
>> > > >> this.
>> > > >>
>> > > >> -igor
>> > > >>
>> > > >> On Tue, Jul 14, 2009 at 3:47 AM, Altuğ B. Altıntaş<
>> altuga@gmail.com>
>> > > >> wrote:
>> > > >> > Also I have a problem like yours.
>> > > >> >
>> > > >> > Servlet session and Wicket's session are different so you are
>> > getting
>> > > >> nul.
>> > > >> > Just debug your application and you will see that they have
>> > different
>> > > >> > session Id's.
>> > > >> >
>> > > >> > I tried to use WicketSessionFilter but it doesn't work.
>> > > >> >
>> > > >> > I am using wicket 1.3.5.
>> > > >> >
>> > > >> > Cheers...
>> > > >> >
>> > > >> > Altug.
>> > > >> >
>> > > >> > 2009/6/23 danisevsky <da...@gmail.com>
>> > > >> >
>> > > >> >> hello, I am using MyMultiFileUploadServlet for uploading files
>> and
>> > in
>> > > >> some
>> > > >> >> wicket component I need find out how many files was uploaded.
>> > > >> >> I was trying to set this number to the HttpSession in
>> > > >> >> MyMultiFileUploadServlet and get it in the component:
>> > > >> >>
>> > > >> >>                    HttpSession httpSession = ((WebRequest)
>> > > >> >> getRequest()).getHttpServletRequest()
>> > > >> >>                            .getSession();
>> > > >> >> String count = httpSession
>> > > >> >>                            .getAttribute("filesCount");
>> > > >> >>
>> > > >> >> but count is always null. Is there any way how to get some data
>> > from
>> > > >> >> servlet? Thanks
>> > > >> >>
>> > > >> >
>> > > >> >
>> > > >> >
>> > > >> > --
>> > > >> > Altuğ.
>> > > >> >
>> > > >>
>> > > >>
>> ---------------------------------------------------------------------
>> > > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > > >> For additional commands, e-mail: users-help@wicket.apache.org
>> > > >>
>> > > >>
>> > > >
>> > > >
>> > > > --
>> > > > Altuğ.
>> > > >
>> > >
>> > > ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > > For additional commands, e-mail: users-help@wicket.apache.org
>> > >
>> > >
>> >
>> >
>> > --
>> > Altuğ.
>> >
>>
>>
>>
>> --
>> Fernando Wermus.
>>
>> www.linkedin.com/in/fernandowermus
>>
>
>
>
> --
> Altuğ.
>



-- 
Altuğ.

Re: how to get some data from servlet

Posted by "Altuğ B. Altıntaş" <al...@gmail.com>.
I will post my codes. But now i catched a very very strange position in
WicketSessionFilter .  Let me explain :

I used WicketSessionFilter and a Simple UploadServlet as Igor said.

I tested my application using Firefox 3. It gives :

java.lang.IllegalStateException: you can only locate or create sessions in
the context of a request cycle

bla bla bla ...

I tried to debug WicketSessionFilter , I can see that Filter runs and sets
the Session into Thread but then My Servlet doesn't get the Session because
some how WicketSessionFilter 's finally block runs and Session.unset()
method executes.

I think my Servlet can't catch the Session in Thread that
WicketSessionFilter puts or something like that.

The most strange part is : When I tested my application using Internet
Explorer 8, WOOWs , It works. My Upload servlet can reach the same Session
without any exception.  I think It means WicketSessionFilter and
UploadServlet runs in proper order.

Also I tested my application in Chrome, and I get the same exception :

java.lang.IllegalStateException: you can only locate or create sessions in
the context of a request cycle

It likes  producer and consumer problem.

Sessions in Wicket will kill me :)

Also I set up Wicket examples and I can see WicketSessionFilter  runs
properly.

Any suggestions ?

Thank you everybody.

Altug.


2009/7/23 Fernando Wermus <fe...@gmail.com>

> Could you show to us the whole code? I mean, the page or panel that upload
> the files as well the IRequestTarget class you have implemented?
>
> On Thu, Jul 23, 2009 at 10:31 AM, Altuğ B. Altıntaş <altuga@gmail.com
> >wrote:
>
> > Hi all ;
> >
> > I can't use WicketSessionFilter maybe because I am using Apache Shiro
> (old
> > name is Apache Kİ).
> >
> > In fact Fernando's solution works; Now I can reach and use Session inside
> > UploadRequestTarget which implements IRequestTarget.
> >
> > But then I realized that I reach a different Session object in
> > UploadRequestTarget class. It creates a new Session so i can  NOT access
> it
> > in other WebPages.
> >
> > In my Application class;
> >
> >  @Override
> >    public final Session newSession(Request request, Response response)
> > {
> >            return new MySession(request);
> >    }
> >
> > Are there any way to access all Sessions or stop creating a new Session
> in
> > UploadRequestTarget (which implements IRequestTarget)
> >
> > Thanks.
> >
> > Altug.
> >
> > 2009/7/20 Igor Vaynberg <ig...@gmail.com>
> >
> > > see WicketSessionFilter
> > >
> > > -igor
> > >
> > > On Sun, Jul 19, 2009 at 3:20 PM, Altuğ B. Altıntaş<al...@gmail.com>
> > > wrote:
> > > > Hi Igor;
> > > >
> > > > I found the problem; problem is when i hit my UploadServlet via
> > http-get
> > > > method , i simply write the url and hit the enter then below code is
> > > working
> > > >
> > > >  Session wicketSession = Session.get();
> > > >
> > > > I can get wicket Session, wow !! it is great...
> > > >
> > > > BUT ...
> > > >
> > > > When i hit  my UploadServlet via http-post method, swfupload access
> in
> > > that
> > > > way then i can NOT access wicketSession.
> > > >
> > > > I mean this code :
> > > >
> > > >  Session wicketSession = Session.get();
> > > >
> > > > it throws :
> > > >
> > > > java.lang.IllegalStateException: you can only locate or create
> sessions
> > > in
> > > > the context of a request cycle
> > > >
> > > > Any idea ?
> > > >
> > > > Thanks
> > > >
> > > > Altug..
> > > >
> > > >
> > > > 2009/7/14 Igor Vaynberg <ig...@gmail.com>
> > > >
> > > >> that doesnt make any sense. all things within the webapp share the
> > > >> session. you guys are welcome to create a quickstart that replicates
> > > >> this.
> > > >>
> > > >> -igor
> > > >>
> > > >> On Tue, Jul 14, 2009 at 3:47 AM, Altuğ B. Altıntaş<altuga@gmail.com
> >
> > > >> wrote:
> > > >> > Also I have a problem like yours.
> > > >> >
> > > >> > Servlet session and Wicket's session are different so you are
> > getting
> > > >> nul.
> > > >> > Just debug your application and you will see that they have
> > different
> > > >> > session Id's.
> > > >> >
> > > >> > I tried to use WicketSessionFilter but it doesn't work.
> > > >> >
> > > >> > I am using wicket 1.3.5.
> > > >> >
> > > >> > Cheers...
> > > >> >
> > > >> > Altug.
> > > >> >
> > > >> > 2009/6/23 danisevsky <da...@gmail.com>
> > > >> >
> > > >> >> hello, I am using MyMultiFileUploadServlet for uploading files
> and
> > in
> > > >> some
> > > >> >> wicket component I need find out how many files was uploaded.
> > > >> >> I was trying to set this number to the HttpSession in
> > > >> >> MyMultiFileUploadServlet and get it in the component:
> > > >> >>
> > > >> >>                    HttpSession httpSession = ((WebRequest)
> > > >> >> getRequest()).getHttpServletRequest()
> > > >> >>                            .getSession();
> > > >> >> String count = httpSession
> > > >> >>                            .getAttribute("filesCount");
> > > >> >>
> > > >> >> but count is always null. Is there any way how to get some data
> > from
> > > >> >> servlet? Thanks
> > > >> >>
> > > >> >
> > > >> >
> > > >> >
> > > >> > --
> > > >> > Altuğ.
> > > >> >
> > > >>
> > > >>
> ---------------------------------------------------------------------
> > > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > >> For additional commands, e-mail: users-help@wicket.apache.org
> > > >>
> > > >>
> > > >
> > > >
> > > > --
> > > > Altuğ.
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> >
> > --
> > Altuğ.
> >
>
>
>
> --
> Fernando Wermus.
>
> www.linkedin.com/in/fernandowermus
>



-- 
Altuğ.

Re: how to get some data from servlet

Posted by Fernando Wermus <fe...@gmail.com>.
Could you show to us the whole code? I mean, the page or panel that upload
the files as well the IRequestTarget class you have implemented?

On Thu, Jul 23, 2009 at 10:31 AM, Altuğ B. Altıntaş <al...@gmail.com>wrote:

> Hi all ;
>
> I can't use WicketSessionFilter maybe because I am using Apache Shiro (old
> name is Apache Kİ).
>
> In fact Fernando's solution works; Now I can reach and use Session inside
> UploadRequestTarget which implements IRequestTarget.
>
> But then I realized that I reach a different Session object in
> UploadRequestTarget class. It creates a new Session so i can  NOT access it
> in other WebPages.
>
> In my Application class;
>
>  @Override
>    public final Session newSession(Request request, Response response)
> {
>            return new MySession(request);
>    }
>
> Are there any way to access all Sessions or stop creating a new Session in
> UploadRequestTarget (which implements IRequestTarget)
>
> Thanks.
>
> Altug.
>
> 2009/7/20 Igor Vaynberg <ig...@gmail.com>
>
> > see WicketSessionFilter
> >
> > -igor
> >
> > On Sun, Jul 19, 2009 at 3:20 PM, Altuğ B. Altıntaş<al...@gmail.com>
> > wrote:
> > > Hi Igor;
> > >
> > > I found the problem; problem is when i hit my UploadServlet via
> http-get
> > > method , i simply write the url and hit the enter then below code is
> > working
> > >
> > >  Session wicketSession = Session.get();
> > >
> > > I can get wicket Session, wow !! it is great...
> > >
> > > BUT ...
> > >
> > > When i hit  my UploadServlet via http-post method, swfupload access in
> > that
> > > way then i can NOT access wicketSession.
> > >
> > > I mean this code :
> > >
> > >  Session wicketSession = Session.get();
> > >
> > > it throws :
> > >
> > > java.lang.IllegalStateException: you can only locate or create sessions
> > in
> > > the context of a request cycle
> > >
> > > Any idea ?
> > >
> > > Thanks
> > >
> > > Altug..
> > >
> > >
> > > 2009/7/14 Igor Vaynberg <ig...@gmail.com>
> > >
> > >> that doesnt make any sense. all things within the webapp share the
> > >> session. you guys are welcome to create a quickstart that replicates
> > >> this.
> > >>
> > >> -igor
> > >>
> > >> On Tue, Jul 14, 2009 at 3:47 AM, Altuğ B. Altıntaş<al...@gmail.com>
> > >> wrote:
> > >> > Also I have a problem like yours.
> > >> >
> > >> > Servlet session and Wicket's session are different so you are
> getting
> > >> nul.
> > >> > Just debug your application and you will see that they have
> different
> > >> > session Id's.
> > >> >
> > >> > I tried to use WicketSessionFilter but it doesn't work.
> > >> >
> > >> > I am using wicket 1.3.5.
> > >> >
> > >> > Cheers...
> > >> >
> > >> > Altug.
> > >> >
> > >> > 2009/6/23 danisevsky <da...@gmail.com>
> > >> >
> > >> >> hello, I am using MyMultiFileUploadServlet for uploading files and
> in
> > >> some
> > >> >> wicket component I need find out how many files was uploaded.
> > >> >> I was trying to set this number to the HttpSession in
> > >> >> MyMultiFileUploadServlet and get it in the component:
> > >> >>
> > >> >>                    HttpSession httpSession = ((WebRequest)
> > >> >> getRequest()).getHttpServletRequest()
> > >> >>                            .getSession();
> > >> >> String count = httpSession
> > >> >>                            .getAttribute("filesCount");
> > >> >>
> > >> >> but count is always null. Is there any way how to get some data
> from
> > >> >> servlet? Thanks
> > >> >>
> > >> >
> > >> >
> > >> >
> > >> > --
> > >> > Altuğ.
> > >> >
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > >> For additional commands, e-mail: users-help@wicket.apache.org
> > >>
> > >>
> > >
> > >
> > > --
> > > Altuğ.
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
>
> --
> Altuğ.
>



-- 
Fernando Wermus.

www.linkedin.com/in/fernandowermus

Re: how to get some data from servlet

Posted by "Altuğ B. Altıntaş" <al...@gmail.com>.
Hi all ;

I can't use WicketSessionFilter maybe because I am using Apache Shiro (old
name is Apache Kİ).

In fact Fernando's solution works; Now I can reach and use Session inside
UploadRequestTarget which implements IRequestTarget.

But then I realized that I reach a different Session object in
UploadRequestTarget class. It creates a new Session so i can  NOT access it
in other WebPages.

In my Application class;

 @Override
    public final Session newSession(Request request, Response response)
{
            return new MySession(request);
    }

Are there any way to access all Sessions or stop creating a new Session in
UploadRequestTarget (which implements IRequestTarget)

Thanks.

Altug.

2009/7/20 Igor Vaynberg <ig...@gmail.com>

> see WicketSessionFilter
>
> -igor
>
> On Sun, Jul 19, 2009 at 3:20 PM, Altuğ B. Altıntaş<al...@gmail.com>
> wrote:
> > Hi Igor;
> >
> > I found the problem; problem is when i hit my UploadServlet via http-get
> > method , i simply write the url and hit the enter then below code is
> working
> >
> >  Session wicketSession = Session.get();
> >
> > I can get wicket Session, wow !! it is great...
> >
> > BUT ...
> >
> > When i hit  my UploadServlet via http-post method, swfupload access in
> that
> > way then i can NOT access wicketSession.
> >
> > I mean this code :
> >
> >  Session wicketSession = Session.get();
> >
> > it throws :
> >
> > java.lang.IllegalStateException: you can only locate or create sessions
> in
> > the context of a request cycle
> >
> > Any idea ?
> >
> > Thanks
> >
> > Altug..
> >
> >
> > 2009/7/14 Igor Vaynberg <ig...@gmail.com>
> >
> >> that doesnt make any sense. all things within the webapp share the
> >> session. you guys are welcome to create a quickstart that replicates
> >> this.
> >>
> >> -igor
> >>
> >> On Tue, Jul 14, 2009 at 3:47 AM, Altuğ B. Altıntaş<al...@gmail.com>
> >> wrote:
> >> > Also I have a problem like yours.
> >> >
> >> > Servlet session and Wicket's session are different so you are getting
> >> nul.
> >> > Just debug your application and you will see that they have different
> >> > session Id's.
> >> >
> >> > I tried to use WicketSessionFilter but it doesn't work.
> >> >
> >> > I am using wicket 1.3.5.
> >> >
> >> > Cheers...
> >> >
> >> > Altug.
> >> >
> >> > 2009/6/23 danisevsky <da...@gmail.com>
> >> >
> >> >> hello, I am using MyMultiFileUploadServlet for uploading files and in
> >> some
> >> >> wicket component I need find out how many files was uploaded.
> >> >> I was trying to set this number to the HttpSession in
> >> >> MyMultiFileUploadServlet and get it in the component:
> >> >>
> >> >>                    HttpSession httpSession = ((WebRequest)
> >> >> getRequest()).getHttpServletRequest()
> >> >>                            .getSession();
> >> >> String count = httpSession
> >> >>                            .getAttribute("filesCount");
> >> >>
> >> >> but count is always null. Is there any way how to get some data from
> >> >> servlet? Thanks
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Altuğ.
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> >
> > --
> > Altuğ.
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Altuğ.

Re: how to get some data from servlet

Posted by Igor Vaynberg <ig...@gmail.com>.
see WicketSessionFilter

-igor

On Sun, Jul 19, 2009 at 3:20 PM, Altuğ B. Altıntaş<al...@gmail.com> wrote:
> Hi Igor;
>
> I found the problem; problem is when i hit my UploadServlet via http-get
> method , i simply write the url and hit the enter then below code is working
>
>  Session wicketSession = Session.get();
>
> I can get wicket Session, wow !! it is great...
>
> BUT ...
>
> When i hit  my UploadServlet via http-post method, swfupload access in that
> way then i can NOT access wicketSession.
>
> I mean this code :
>
>  Session wicketSession = Session.get();
>
> it throws :
>
> java.lang.IllegalStateException: you can only locate or create sessions in
> the context of a request cycle
>
> Any idea ?
>
> Thanks
>
> Altug..
>
>
> 2009/7/14 Igor Vaynberg <ig...@gmail.com>
>
>> that doesnt make any sense. all things within the webapp share the
>> session. you guys are welcome to create a quickstart that replicates
>> this.
>>
>> -igor
>>
>> On Tue, Jul 14, 2009 at 3:47 AM, Altuğ B. Altıntaş<al...@gmail.com>
>> wrote:
>> > Also I have a problem like yours.
>> >
>> > Servlet session and Wicket's session are different so you are getting
>> nul.
>> > Just debug your application and you will see that they have different
>> > session Id's.
>> >
>> > I tried to use WicketSessionFilter but it doesn't work.
>> >
>> > I am using wicket 1.3.5.
>> >
>> > Cheers...
>> >
>> > Altug.
>> >
>> > 2009/6/23 danisevsky <da...@gmail.com>
>> >
>> >> hello, I am using MyMultiFileUploadServlet for uploading files and in
>> some
>> >> wicket component I need find out how many files was uploaded.
>> >> I was trying to set this number to the HttpSession in
>> >> MyMultiFileUploadServlet and get it in the component:
>> >>
>> >>                    HttpSession httpSession = ((WebRequest)
>> >> getRequest()).getHttpServletRequest()
>> >>                            .getSession();
>> >> String count = httpSession
>> >>                            .getAttribute("filesCount");
>> >>
>> >> but count is always null. Is there any way how to get some data from
>> >> servlet? Thanks
>> >>
>> >
>> >
>> >
>> > --
>> > Altuğ.
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> --
> Altuğ.
>

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


Re: how to get some data from servlet

Posted by bgooren <ba...@iswd.nl>.
Thanks Fernando, I was looking for some code like this!


Fernando Wermus-2 wrote:
> 
> Hi,
> 
> Instead using a servlet you could try the following (you can find the
> whole
> code at wicketstuff pickwick )
> 
> This way you will have the session because your are into the
> requestCycle....
> 
> On your WicketApp....
> 
>         mount(new URIRequestTargetUrlCodingStrategy("/upload") {
>             @Override public IRequestTarget decode(RequestParameters
> requestParameters) {
>                 try {
>                     return new
> UploadRequestTarget(decodeParameters(requestParameters).getString("uri"));
>                 } catch (Exception e) {
>                     throw new WicketRuntimeException(e);
>                 }
>             }
>         });
> 
> Your own class for uploading images or whatever you want....
> 
> public class UploadRequestTarget implements IRequestTarget {
>     String parameters;
> 
>     public UploadRequestTarget(String parameters) {
>         this.parameters=uri;
>     }
> 
>     public void detach(RequestCycle requestCycle) {}
> 
>     public void respond(RequestCycle requestCycle) {
>         HttpServletRequest
> request=((WebRequest)requestCycle.getRequest()).getHttpServletRequest();
>         HttpServletResponse
> response=((WebResponse)requestCycle.getResponse()).getHttpServletResponse();
> 
>         response.setHeader("Connection","close");
> 
>         FileItemFactory factory = new DiskFileItemFactory();
>         ServletFileUpload upload = new ServletFileUpload(factory);
> 
>         List items=null;
>         PrintWriter out=null;
>         try {
>             out = response.getWriter();
>             items = upload.parseRequest(request);
> 
>             for (int i = 0; i < items.size(); i++) {
>                 DiskFileItem item = (DiskFileItem) items.get(i);
>                 // As we are interested not in regular form fields, we
> filter only files
>                 if (!item.isFormField()) {
>                         String fileName=COMPLETE IT
>                         item.write(new File(fileName));
>                         out.print("RESP.100");
>                         out.flush();
>                 }
>             }
>         } catch (FileUploadException e1) {
>             out.print("RESP.200");
>             // flush the stream to speed up applet notification
>             out.flush();
>             e1.printStackTrace();
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
> 
>     }
> 
> 
> On Sun, Jul 19, 2009 at 3:20 PM, Altuğ B. Altıntaş <al...@gmail.com>
> wrote:
> 
>> Hi Igor;
>>
>> I found the problem; problem is when i hit my UploadServlet via http-get
>> method , i simply write the url and hit the enter then below code is
>> working
>>
>>  Session wicketSession = Session.get();
>>
>> I can get wicket Session, wow !! it is great...
>>
>> BUT ...
>>
>> When i hit  my UploadServlet via http-post method, swfupload access in
>> that
>> way then i can NOT access wicketSession.
>>
>> I mean this code :
>>
>>  Session wicketSession = Session.get();
>>
>> it throws :
>>
>> java.lang.IllegalStateException: you can only locate or create sessions
>> in
>> the context of a request cycle
>>
>> Any idea ?
>>
>> Thanks
>>
>> Altug..
>>
>>
>> 2009/7/14 Igor Vaynberg <ig...@gmail.com>
>>
>> > that doesnt make any sense. all things within the webapp share the
>> > session. you guys are welcome to create a quickstart that replicates
>> > this.
>> >
>> > -igor
>> >
>> > On Tue, Jul 14, 2009 at 3:47 AM, Altuğ B. Altıntaş<al...@gmail.com>
>> > wrote:
>> > > Also I have a problem like yours.
>> > >
>> > > Servlet session and Wicket's session are different so you are getting
>> > nul.
>> > > Just debug your application and you will see that they have different
>> > > session Id's.
>> > >
>> > > I tried to use WicketSessionFilter but it doesn't work.
>> > >
>> > > I am using wicket 1.3.5.
>> > >
>> > > Cheers...
>> > >
>> > > Altug.
>> > >
>> > > 2009/6/23 danisevsky <da...@gmail.com>
>> > >
>> > >> hello, I am using MyMultiFileUploadServlet for uploading files and
>> in
>> > some
>> > >> wicket component I need find out how many files was uploaded.
>> > >> I was trying to set this number to the HttpSession in
>> > >> MyMultiFileUploadServlet and get it in the component:
>> > >>
>> > >>                    HttpSession httpSession = ((WebRequest)
>> > >> getRequest()).getHttpServletRequest()
>> > >>                            .getSession();
>> > >> String count = httpSession
>> > >>                            .getAttribute("filesCount");
>> > >>
>> > >> but count is always null. Is there any way how to get some data from
>> > >> servlet? Thanks
>> > >>
>> > >
>> > >
>> > >
>> > > --
>> > > Altuğ.
>> > >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>>
>>
>> --
>> Altuğ.
>>
> 
> 
> 
> -- 
> Fernando Wermus.
> 
> www.linkedin.com/in/fernandowermus
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-get-some-data-from-servlet-tp24166796p24695219.html
Sent from the Wicket - User 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 some data from servlet

Posted by "Altuğ B. Altıntaş" <al...@gmail.com>.
Great solution Fernando.

It works !!!

Thanks.


2009/7/20 Fernando Wermus <fe...@gmail.com>

> Hi,
>
> Instead using a servlet you could try the following (you can find the whole
> code at wicketstuff pickwick )
>
> This way you will have the session because your are into the
> requestCycle....
>
> On your WicketApp....
>
>        mount(new URIRequestTargetUrlCodingStrategy("/upload") {
>            @Override public IRequestTarget decode(RequestParameters
> requestParameters) {
>                try {
>                    return new
> UploadRequestTarget(decodeParameters(requestParameters).getString("uri"));
>                } catch (Exception e) {
>                    throw new WicketRuntimeException(e);
>                }
>            }
>        });
>
> Your own class for uploading images or whatever you want....
>
> public class UploadRequestTarget implements IRequestTarget {
>    String parameters;
>
>    public UploadRequestTarget(String parameters) {
>        this.parameters=uri;
>    }
>
>    public void detach(RequestCycle requestCycle) {}
>
>    public void respond(RequestCycle requestCycle) {
>        HttpServletRequest
> request=((WebRequest)requestCycle.getRequest()).getHttpServletRequest();
>        HttpServletResponse
>
> response=((WebResponse)requestCycle.getResponse()).getHttpServletResponse();
>
>        response.setHeader("Connection","close");
>
>        FileItemFactory factory = new DiskFileItemFactory();
>        ServletFileUpload upload = new ServletFileUpload(factory);
>
>        List items=null;
>        PrintWriter out=null;
>        try {
>            out = response.getWriter();
>            items = upload.parseRequest(request);
>
>            for (int i = 0; i < items.size(); i++) {
>                DiskFileItem item = (DiskFileItem) items.get(i);
>                // As we are interested not in regular form fields, we
> filter only files
>                if (!item.isFormField()) {
>                        String fileName=COMPLETE IT
>                        item.write(new File(fileName));
>                        out.print("RESP.100");
>                        out.flush();
>                }
>            }
>        } catch (FileUploadException e1) {
>            out.print("RESP.200");
>            // flush the stream to speed up applet notification
>            out.flush();
>            e1.printStackTrace();
>        } catch (Exception e) {
>            e.printStackTrace();
>         }
>
>    }
>
>
> On Sun, Jul 19, 2009 at 3:20 PM, Altuğ B. Altıntaş <al...@gmail.com>
> wrote:
>
> > Hi Igor;
> >
> > I found the problem; problem is when i hit my UploadServlet via http-get
> > method , i simply write the url and hit the enter then below code is
> > working
> >
> >  Session wicketSession = Session.get();
> >
> > I can get wicket Session, wow !! it is great...
> >
> > BUT ...
> >
> > When i hit  my UploadServlet via http-post method, swfupload access in
> that
> > way then i can NOT access wicketSession.
> >
> > I mean this code :
> >
> >  Session wicketSession = Session.get();
> >
> > it throws :
> >
> > java.lang.IllegalStateException: you can only locate or create sessions
> in
> > the context of a request cycle
> >
> > Any idea ?
> >
> > Thanks
> >
> > Altug..
> >
> >
> > 2009/7/14 Igor Vaynberg <ig...@gmail.com>
> >
> > > that doesnt make any sense. all things within the webapp share the
> > > session. you guys are welcome to create a quickstart that replicates
> > > this.
> > >
> > > -igor
> > >
> > > On Tue, Jul 14, 2009 at 3:47 AM, Altuğ B. Altıntaş<al...@gmail.com>
> > > wrote:
> > > > Also I have a problem like yours.
> > > >
> > > > Servlet session and Wicket's session are different so you are getting
> > > nul.
> > > > Just debug your application and you will see that they have different
> > > > session Id's.
> > > >
> > > > I tried to use WicketSessionFilter but it doesn't work.
> > > >
> > > > I am using wicket 1.3.5.
> > > >
> > > > Cheers...
> > > >
> > > > Altug.
> > > >
> > > > 2009/6/23 danisevsky <da...@gmail.com>
> > > >
> > > >> hello, I am using MyMultiFileUploadServlet for uploading files and
> in
> > > some
> > > >> wicket component I need find out how many files was uploaded.
> > > >> I was trying to set this number to the HttpSession in
> > > >> MyMultiFileUploadServlet and get it in the component:
> > > >>
> > > >>                    HttpSession httpSession = ((WebRequest)
> > > >> getRequest()).getHttpServletRequest()
> > > >>                            .getSession();
> > > >> String count = httpSession
> > > >>                            .getAttribute("filesCount");
> > > >>
> > > >> but count is always null. Is there any way how to get some data from
> > > >> servlet? Thanks
> > > >>
> > > >
> > > >
> > > >
> > > > --
> > > > Altuğ.
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> >
> > --
> > Altuğ.
> >
>
>
>
> --
> Fernando Wermus.
>
> www.linkedin.com/in/fernandowermus
>



-- 
Altuğ.

Re: how to get some data from servlet

Posted by Fernando Wermus <fe...@gmail.com>.
Hi,

Instead using a servlet you could try the following (you can find the whole
code at wicketstuff pickwick )

This way you will have the session because your are into the
requestCycle....

On your WicketApp....

        mount(new URIRequestTargetUrlCodingStrategy("/upload") {
            @Override public IRequestTarget decode(RequestParameters
requestParameters) {
                try {
                    return new
UploadRequestTarget(decodeParameters(requestParameters).getString("uri"));
                } catch (Exception e) {
                    throw new WicketRuntimeException(e);
                }
            }
        });

Your own class for uploading images or whatever you want....

public class UploadRequestTarget implements IRequestTarget {
    String parameters;

    public UploadRequestTarget(String parameters) {
        this.parameters=uri;
    }

    public void detach(RequestCycle requestCycle) {}

    public void respond(RequestCycle requestCycle) {
        HttpServletRequest
request=((WebRequest)requestCycle.getRequest()).getHttpServletRequest();
        HttpServletResponse
response=((WebResponse)requestCycle.getResponse()).getHttpServletResponse();

        response.setHeader("Connection","close");

        FileItemFactory factory = new DiskFileItemFactory();
        ServletFileUpload upload = new ServletFileUpload(factory);

        List items=null;
        PrintWriter out=null;
        try {
            out = response.getWriter();
            items = upload.parseRequest(request);

            for (int i = 0; i < items.size(); i++) {
                DiskFileItem item = (DiskFileItem) items.get(i);
                // As we are interested not in regular form fields, we
filter only files
                if (!item.isFormField()) {
                        String fileName=COMPLETE IT
                        item.write(new File(fileName));
                        out.print("RESP.100");
                        out.flush();
                }
            }
        } catch (FileUploadException e1) {
            out.print("RESP.200");
            // flush the stream to speed up applet notification
            out.flush();
            e1.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


On Sun, Jul 19, 2009 at 3:20 PM, Altuğ B. Altıntaş <al...@gmail.com> wrote:

> Hi Igor;
>
> I found the problem; problem is when i hit my UploadServlet via http-get
> method , i simply write the url and hit the enter then below code is
> working
>
>  Session wicketSession = Session.get();
>
> I can get wicket Session, wow !! it is great...
>
> BUT ...
>
> When i hit  my UploadServlet via http-post method, swfupload access in that
> way then i can NOT access wicketSession.
>
> I mean this code :
>
>  Session wicketSession = Session.get();
>
> it throws :
>
> java.lang.IllegalStateException: you can only locate or create sessions in
> the context of a request cycle
>
> Any idea ?
>
> Thanks
>
> Altug..
>
>
> 2009/7/14 Igor Vaynberg <ig...@gmail.com>
>
> > that doesnt make any sense. all things within the webapp share the
> > session. you guys are welcome to create a quickstart that replicates
> > this.
> >
> > -igor
> >
> > On Tue, Jul 14, 2009 at 3:47 AM, Altuğ B. Altıntaş<al...@gmail.com>
> > wrote:
> > > Also I have a problem like yours.
> > >
> > > Servlet session and Wicket's session are different so you are getting
> > nul.
> > > Just debug your application and you will see that they have different
> > > session Id's.
> > >
> > > I tried to use WicketSessionFilter but it doesn't work.
> > >
> > > I am using wicket 1.3.5.
> > >
> > > Cheers...
> > >
> > > Altug.
> > >
> > > 2009/6/23 danisevsky <da...@gmail.com>
> > >
> > >> hello, I am using MyMultiFileUploadServlet for uploading files and in
> > some
> > >> wicket component I need find out how many files was uploaded.
> > >> I was trying to set this number to the HttpSession in
> > >> MyMultiFileUploadServlet and get it in the component:
> > >>
> > >>                    HttpSession httpSession = ((WebRequest)
> > >> getRequest()).getHttpServletRequest()
> > >>                            .getSession();
> > >> String count = httpSession
> > >>                            .getAttribute("filesCount");
> > >>
> > >> but count is always null. Is there any way how to get some data from
> > >> servlet? Thanks
> > >>
> > >
> > >
> > >
> > > --
> > > Altuğ.
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
>
> --
> Altuğ.
>



-- 
Fernando Wermus.

www.linkedin.com/in/fernandowermus

Re: how to get some data from servlet

Posted by "Altuğ B. Altıntaş" <al...@gmail.com>.
Hi Igor;

I found the problem; problem is when i hit my UploadServlet via http-get
method , i simply write the url and hit the enter then below code is working

 Session wicketSession = Session.get();

I can get wicket Session, wow !! it is great...

BUT ...

When i hit  my UploadServlet via http-post method, swfupload access in that
way then i can NOT access wicketSession.

I mean this code :

 Session wicketSession = Session.get();

it throws :

java.lang.IllegalStateException: you can only locate or create sessions in
the context of a request cycle

Any idea ?

Thanks

Altug..


2009/7/14 Igor Vaynberg <ig...@gmail.com>

> that doesnt make any sense. all things within the webapp share the
> session. you guys are welcome to create a quickstart that replicates
> this.
>
> -igor
>
> On Tue, Jul 14, 2009 at 3:47 AM, Altuğ B. Altıntaş<al...@gmail.com>
> wrote:
> > Also I have a problem like yours.
> >
> > Servlet session and Wicket's session are different so you are getting
> nul.
> > Just debug your application and you will see that they have different
> > session Id's.
> >
> > I tried to use WicketSessionFilter but it doesn't work.
> >
> > I am using wicket 1.3.5.
> >
> > Cheers...
> >
> > Altug.
> >
> > 2009/6/23 danisevsky <da...@gmail.com>
> >
> >> hello, I am using MyMultiFileUploadServlet for uploading files and in
> some
> >> wicket component I need find out how many files was uploaded.
> >> I was trying to set this number to the HttpSession in
> >> MyMultiFileUploadServlet and get it in the component:
> >>
> >>                    HttpSession httpSession = ((WebRequest)
> >> getRequest()).getHttpServletRequest()
> >>                            .getSession();
> >> String count = httpSession
> >>                            .getAttribute("filesCount");
> >>
> >> but count is always null. Is there any way how to get some data from
> >> servlet? Thanks
> >>
> >
> >
> >
> > --
> > Altuğ.
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Altuğ.

Re: how to get some data from servlet

Posted by Igor Vaynberg <ig...@gmail.com>.
that doesnt make any sense. all things within the webapp share the
session. you guys are welcome to create a quickstart that replicates
this.

-igor

On Tue, Jul 14, 2009 at 3:47 AM, Altuğ B. Altıntaş<al...@gmail.com> wrote:
> Also I have a problem like yours.
>
> Servlet session and Wicket's session are different so you are getting nul.
> Just debug your application and you will see that they have different
> session Id's.
>
> I tried to use WicketSessionFilter but it doesn't work.
>
> I am using wicket 1.3.5.
>
> Cheers...
>
> Altug.
>
> 2009/6/23 danisevsky <da...@gmail.com>
>
>> hello, I am using MyMultiFileUploadServlet for uploading files and in some
>> wicket component I need find out how many files was uploaded.
>> I was trying to set this number to the HttpSession in
>> MyMultiFileUploadServlet and get it in the component:
>>
>>                    HttpSession httpSession = ((WebRequest)
>> getRequest()).getHttpServletRequest()
>>                            .getSession();
>> String count = httpSession
>>                            .getAttribute("filesCount");
>>
>> but count is always null. Is there any way how to get some data from
>> servlet? Thanks
>>
>
>
>
> --
> Altuğ.
>

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