You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Stephen Nelson <st...@eccostudio.com> on 2009/10/01 15:47:22 UTC

Custom session is null

Hello Wicket Users,

I'm a beginner to wicket having previously used Spring MVC and Struts  
1/2 so definitely from the other side as far as web frameworks go!

Anyway I have a custom session to store a logged-in user; a panel  
component which performs the login; and a form web page.

I'm using Wicket 1.4.1 on Glassfish 2.x and Spring 2.5.6 to hook it  
all together.

I have bookmarkable pages for the login and the form page.

Anyway when I deploy the app I go to login. This works fine and I have  
logger statements when storing the user in the session. Now I go to  
the form page, which after clicking submit, checks if you're logged  
in. This test fails and I'm asked to login. If I now do a further  
login I can return to this form page and it functions as expected. I'm  
not sure why this session object is null the first time around.

If you want me to provide a few code snippets I can.

Many thanks

Stephen

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


Re: Custom session is null

Posted by Stephen Nelson <st...@eccostudio.com>.
On 1 Oct 2009, at 17:06, Pedro Santos wrote:

> The cookie used to keep session information. When you use link to  
> access the
> form page, you are sending the session cookie stored on browser back  
> to
> server, that now can to know with what session he has to work.
>
> "Creates a cookie, a small amount of information sent by a servlet  
> to a Web
> browser, saved by the browser, and later sent back to the server. A  
> cookie's
> value can uniquely identify a client, so cookies are commonly used for
> session management. "
> http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/http/Cookie.html
>
> -- 
> Pedro Henrique Oliveira dos Santos

Sure, I'm aware of how cookies work but there shouldn't be a  
difference, in terms of whether a cookie is sent, from clicking a link  
to typing in a url. So long as the domain matches that of the cookie  
it will be sent every request.

So I'm not sure of the difference between accessing the page directly,  
or accessing the page through a link. My session should be retrieved  
on each request. This is what I'm not understanding I feel.

--

Stephen Nelson

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


Re: Custom session is null

Posted by Pedro Santos <pe...@gmail.com>.
The cookie used to keep session information. When you use link to access the
form page, you are sending the session cookie stored on browser back to
server, that now can to know with what session he has to work.

"Creates a cookie, a small amount of information sent by a servlet to a Web
browser, saved by the browser, and later sent back to the server. A cookie's
value can uniquely identify a client, so cookies are commonly used for
session management. "
http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/http/Cookie.html

On Thu, Oct 1, 2009 at 11:48 AM, Stephen Nelson <st...@eccostudio.com>wrote:

>
> On 1 Oct 2009, at 15:11, Pedro Santos wrote:
>
>  I have bookmarkable pages for the login and the form page.
>> Now I go to the form page
>> If you using a link to go to form page, for some reason you don't get an
>> cookie on your browser holding your session information. If you just
>> writing
>> the url to form page on browser, you are not passing session information
>> encoded on url because it is bookmarkable.
>>
>> "which implies that the URL will not have any session information encoded
>> in
>> it, and that you can call this page directly without having a session
>> first
>> directly from your browser"
>> http://cwiki.apache.org/WICKET/bookmarkable-pages-and-links.html
>> --
>> Pedro Henrique Oliveira dos Santos
>>
>
> Hi Pedro,
>
> Thanks for the reply. You are correct - I just added a link component on my
> login page to my form page and it now functions as expected.
>
> However I don't quite follow why it doesn't work when manually typing a url
> in. If I'm logged-in I would expect to stay logged-in whether I manually
> type a url or follow a link. Which bit am I misunderstanding?
>
> --
> Stephen Nelson
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Pedro Henrique Oliveira dos Santos

Re: Custom session is null

Posted by Stephen Nelson <st...@eccostudio.com>.
On 1 Oct 2009, at 15:11, Pedro Santos wrote:

> I have bookmarkable pages for the login and the form page.
> Now I go to the form page
> If you using a link to go to form page, for some reason you don't  
> get an
> cookie on your browser holding your session information. If you just  
> writing
> the url to form page on browser, you are not passing session  
> information
> encoded on url because it is bookmarkable.
>
> "which implies that the URL will not have any session information  
> encoded in
> it, and that you can call this page directly without having a  
> session first
> directly from your browser"
> http://cwiki.apache.org/WICKET/bookmarkable-pages-and-links.html
> -- 
> Pedro Henrique Oliveira dos Santos

Hi Pedro,

Thanks for the reply. You are correct - I just added a link component  
on my login page to my form page and it now functions as expected.

However I don't quite follow why it doesn't work when manually typing  
a url in. If I'm logged-in I would expect to stay logged-in whether I  
manually type a url or follow a link. Which bit am I misunderstanding?

--
Stephen Nelson

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


Re: Custom session is null

Posted by Pedro Santos <pe...@gmail.com>.
 I have bookmarkable pages for the login and the form page.
Now I go to the form page
If you using a link to go to form page, for some reason you don't get an
cookie on your browser holding your session information. If you just writing
the url to form page on browser, you are not passing session information
encoded on url because it is bookmarkable.

"which implies that the URL will not have any session information encoded in
it, and that you can call this page directly without having a session first
directly from your browser"
http://cwiki.apache.org/WICKET/bookmarkable-pages-and-links.html

On Thu, Oct 1, 2009 at 10:47 AM, Stephen Nelson <st...@eccostudio.com>wrote:

> Hello Wicket Users,
>
> I'm a beginner to wicket having previously used Spring MVC and Struts 1/2
> so definitely from the other side as far as web frameworks go!
>
> Anyway I have a custom session to store a logged-in user; a panel component
> which performs the login; and a form web page.
>
> I'm using Wicket 1.4.1 on Glassfish 2.x and Spring 2.5.6 to hook it all
> together.
>
> I have bookmarkable pages for the login and the form page.
>
> Anyway when I deploy the app I go to login. This works fine and I have
> logger statements when storing the user in the session. Now I go to the form
> page, which after clicking submit, checks if you're logged in. This test
> fails and I'm asked to login. If I now do a further login I can return to
> this form page and it functions as expected. I'm not sure why this session
> object is null the first time around.
>
> If you want me to provide a few code snippets I can.
>
> Many thanks
>
> Stephen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Pedro Henrique Oliveira dos Santos