I think that would be great. 

In my project I had to use Ajax pattern and I faced similar problem in
accessing Http Session. Ajax request was simply creating new session. As you
can understand in shopping cart application session is the most crucial
thing.
What I did to access session is got the session token from "Document.Url"
and used the session to call the server so that it taps on the existing
session. It worked but this is called "URLRewritting" which is highly unsafe
method.
My code is :

function sendDataToServer(parameters){
        var url =
"<@ofbizUrl>/yourordersofar</@ofbizUrl>;JSESSIONID_ofbiz="+getCookie("JSESSI
ONID_ofbiz");
        request.onreadystatechange =  updateOrderSoFar; //updatePage; 
        takeRequest = true;
        try{
        request.open("POST",url,true);
        request.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
    request.setRequestHeader("Content-length", parameters.length);
    request.setRequestHeader("Connection", "close");
        request.send(parameters);
                }catch(PostNotAllowed) {
//some old versions of Safari browser does not Support POST
                try{
                var uri_get = url+"?" + parameters;
                request.open("GET",uri_get,true);
                request.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
                request.setRequestHeader("Content-length",
parameters.length);
        request.setRequestHeader("Connection", "close");
                request.send(null);
                //alert("Request send to server using Post and url
:"+uri_get);
                }catch(failed){
                        alert("Sorry! your browser is not allowing me to
send any request to server.");
                }
        }
}

If you can give me any better Ideas It will be highly helpful.

Sayoke Shome |  Technical Associate | Techmahindra Ltd. |  BIPL, sector V
,saltlake | mobile : 9831105664 

-----Original Message-----
From: David E Jones [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 19, 2006 6:30 AM
To: [email protected]
Subject: Re: AJAX and HttpSession


It would be great to have an example/poc or two in different parts of  
the project, or even in the example component, that people can look  
at and use as a basis for other parts of the project or  
customizations or whatever.

Given the somewhat chaotic nature of the AJAX world, it might be nice  
to have multiple PoC bits in place to compare things for making a  
decision for other parts.

-David


On Sep 18, 2006, at 6:23 PM, Leon Torres wrote:

> By the way, we'll be publishing a tutorial for using AJAX to create  
> an autocomplete text field sometime this week.
>
> - Leon Torres
> Open Source Strategies Inc.
>
>
> Amit Shinde wrote:
>> That worked! I can get userLogin now but LocalDispatcher with  
>> dispatcher
>> attribute is still null. That is not a big deal as I get the  
>> LocalDispatcher
>> this way -
>> LocalDispatcher dispatcher = GenericDispatcher.getLocalDispatcher 
>> ("local",
>> delegator);
>> Thanks for all the help,
>> Amit Shinde
>> -----Original Message-----
>> From: tibor katelbach [mailto:[EMAIL PROTECTED]
>> Sent: Monday, September 18, 2006 7:32 PM
>> To: [email protected]
>> Subject: Re: AJAX and HttpSession
>> try
>> req.open("POST", "/erp/control/dyna", true);
>> the call has to start from the base.
>> here's mine
>> xhr_object.open("GET", "/PBBO/catalog/control/getimporterror? 
>> date="+new
>> Date().getTime(), true);
>> Tibor
>> On 9/18/06, Amit Shinde <[EMAIL PROTECTED]> wrote:
>>> Lon,
>>>         Heres the URL -
>>>
>>>
>>>
>>> Amit
>>>
>>>
>>> -----Original Message-----
>>> From: Lon Binder [mailto:[EMAIL PROTECTED]
>>> Sent: Monday, September 18, 2006 7:18 PM
>>> To: [email protected]
>>> Subject: RE: AJAX and HttpSession
>>>
>>>
>>> Amit,
>>>
>>> What URL are you requesting?  The app server doesn't know the  
>>> difference
>>> between plain browser requests and ajax requests.  It's just a  
>>> matter of
>>> URL construction.
>>>
>>> - Lon
>>>
>>>
>>> -----Original Message-----
>>> From: Amit Shinde [mailto:[EMAIL PROTECTED]
>>> Sent: Monday, September 18, 2006 9:41 AM
>>> To: [email protected]
>>> Subject: AJAX and HttpSession
>>>
>>> Hello,
>>>         I was wondering if anyone has played with AJAX. I want to  
>>> call a
>>> OFBiz service by making an XMLHttpRequest. I have a  
>>> RequestHandler that
>>> is supposed to process this request. The problem I am facing is of
>>> HttpSession.
>>> Even though I am logged in, I get userLogin, dispatcher and  
>>> delegator
>>> attributes null. Is there a way where we can get our HttpSession
>>> attributes from XMLHttpRequest. Do we need to do any special  
>>> thing or is
>>> this just a limitation?
>>>
>>>         Without a valid HttpSession, I obviously cant run the  
>>> service
>>> unless I pass userLoginId in the XMLHttpRequest and get UserLogin  
>>> value
>>> through delegator.
>>> This approach will pose a security hazard nonetheless.
>>>
>>>         Any insight will be appreciated.
>>>
>>>
>>> Thanks in advance,
>>>
>>> Amit Shinde
>>>
>>>
>>>
>>>
>>>
>>>
>>>


============================================================================================================================

Tech Mahindra, formerly Mahindra-British Telecom.
 
Disclaimer:

This message and the information contained herein is proprietary and 
confidential and subject to the Tech Mahindra policy statement, you may review 
at <a 
href="http://www.techmahindra.com/Disclaimer.html";>http://www.techmahindra.com/Disclaimer.html</a>
 externally and <a 
href="http://tim.techmahindra.com/Disclaimer.html";>http://tim.techmahindra.com/Disclaimer.html</a>
 internally within Tech Mahindra.

============================================================================================================================

Reply via email to