You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Anand Kumar Kalyanasundaram <an...@ERC.MsState.Edu> on 2004/05/03 10:16:51 UTC

retrieve jetspeed session from servlet

Hi,
I have an applet in a velocity portlet that needs
to talk back to a servlet for additional processing. When
the applet does a HttpURLConnection to the servlet, the
servlet somehow seems to pickup the correct session (tomcat
version 4.1). I.e. The session id got by
"$data.getSession().getId()" in the velocity template is
the same as "request.getSession().getId()" in the servlet.
Please correct me if I am wrong here.

My problem is, I am unable to retrieve the JetspeedUser
in the servlet.

The following code in the servlet returns null for
JetspeedUser :

    HttpSession session=request.getSession();
    System.out.println("\n SessionId="+session.getId());

    RunData data = RunDataFactory.getRunData(request,
                      response,
                      getServletConfig());

    JetspeedUser user =
           ((JetspeedRunData)data).getJetspeedUser();

    // user is null

Is there another way to retrieve JetspeedUser ? Thanks in
advance for any possible help.

Anand

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


Re: retrieve jetspeed session from servlet

Posted by Anand K Kalyanasundaram <an...@ERC.MsState.Edu>.

David Sean Taylor wrote:

>
> On May 3, 2004, at 1:16 AM, Anand Kumar Kalyanasundaram wrote:
>
>> Hi,
>> I have an applet in a velocity portlet that needs
>> to talk back to a servlet for additional processing. When
>> the applet does a HttpURLConnection to the servlet, the
>> servlet somehow seems to pickup the correct session (tomcat
>> version 4.1). I.e. The session id got by
>> "$data.getSession().getId()" in the velocity template is
>> the same as "request.getSession().getId()" in the servlet.
>> Please correct me if I am wrong here.
>>
>
>> My problem is, I am unable to retrieve the JetspeedUser
>> in the servlet.
>>
>> The following code in the servlet returns null for
>> JetspeedUser :
>>
>>     HttpSession session=request.getSession();
>>     System.out.println("\n SessionId="+session.getId());
>>
>>     RunData data = RunDataFactory.getRunData(request,
>>                       response,
>>                       getServletConfig());
>>
>>     JetspeedUser user =
>>            ((JetspeedRunData)data).getJetspeedUser();
>>
>>     // user is null
>>
> How are you going to get RunData from a non-Turbine servlet.
> Think about it. That makes absolutely no sense.
> RunData is created by Turbine for each request invocation and is only 
> valid for the duration of that request.

Sorry for the misunderstanding. I am new to jetspeed. From the turbine 
javadocs, 
http://jakarta.apache.org/turbine/turbine-2.3/apidocs/org/apache/turbine/util/RunDataFactory.html,
I got the impression that RunDataFactory (now deprecated) mimics turbine 
and creates RunData initialized with all session information (I am 
passing the request object as a parameter!).

>
>> Is there another way to retrieve JetspeedUser ? Thanks in
>> advance for any possible help.
>>
> If you want to get the current logged on user, go to the session.

Stuart's suggestion: using 'session.getAttribute("turbine.user")' 
worked. Thanks.

>
>
> -- 
> David Sean Taylor
> Bluesunrise Software
> david@bluesunrise.com
> [office]   +01 707 773-4646
> [mobile] +01 707 529 9194
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org



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


Re: retrieve jetspeed session from servlet

Posted by David Sean Taylor <da...@bluesunrise.com>.
On May 3, 2004, at 1:16 AM, Anand Kumar Kalyanasundaram wrote:

> Hi,
> I have an applet in a velocity portlet that needs
> to talk back to a servlet for additional processing. When
> the applet does a HttpURLConnection to the servlet, the
> servlet somehow seems to pickup the correct session (tomcat
> version 4.1). I.e. The session id got by
> "$data.getSession().getId()" in the velocity template is
> the same as "request.getSession().getId()" in the servlet.
> Please correct me if I am wrong here.
>

> My problem is, I am unable to retrieve the JetspeedUser
> in the servlet.
>
> The following code in the servlet returns null for
> JetspeedUser :
>
>     HttpSession session=request.getSession();
>     System.out.println("\n SessionId="+session.getId());
>
>     RunData data = RunDataFactory.getRunData(request,
>                       response,
>                       getServletConfig());
>
>     JetspeedUser user =
>            ((JetspeedRunData)data).getJetspeedUser();
>
>     // user is null
>
How are you going to get RunData from a non-Turbine servlet.
Think about it. That makes absolutely no sense.
RunData is created by Turbine for each request invocation and is only 
valid for the duration of that request.

> Is there another way to retrieve JetspeedUser ? Thanks in
> advance for any possible help.
>
If you want to get the current logged on user, go to the session.


--
David Sean Taylor
Bluesunrise Software
david@bluesunrise.com
[office]   +01 707 773-4646
[mobile] +01 707 529 9194



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