Thanks Steve. Appreciate the help extended. Let me now dig my head into this :-)

On Fri, Feb 27, 2009 at 1:32 PM, Steve Vinoski <vinoski@ieee.org> wrote:
I should have been clearer that the code snippet wasn't complete. It
leaves off where you get a proplist of headers and their values, but
it doesn't fully complete the out/1 function. If you take the function
exactly as I originally showed it but add this line to the bottom it
should be fine:

{status, 200}.

Your task will then be to put your "communicate with J2EE" code in
between the bottom two lines:

Headers = lists:append([proplists:delete("other", Headers1), Other]),
%% insert code to talk to J2EE here
{status, 200}.

For your real code, presumably your J2EE system will return various
status and data to you for return to your web client, so eventually
you'll need to replace that {status,200} with something to convey the
real results.

--steve


On 2/27/09, Saurabh Dutta <saurabh80@gmail.com> wrote:
> Thanks Steve for your reply. I tried using the code snippet you gave me but
> i am getting this error
>
> yaws code at appmod:0 crashed or ret bad
> val:{"connection","keep-alive"}
> Req: {http_request,'GET',{abs_path,"/context"},{1,1}}
>
> Need Help on this too :-)
>
>
> On Fri, Feb 27, 2009 at 4:20 AM, Steve Vinoski <vinoski@ieee.org> wrote:
> >
> > On 2/26/09, Saurabh80 <saurabh80@gmail.com> wrote:
> > >
> > >  Which module and function in yaws does this. basically i want to stream
> the
> > >  request parameters to some other port. so that i can keep yaws as a
> > >  webserver and at the backend do the session management and stuff
> myself.
> > >  I am trying to explore possibilities to use yaws in the j2ee world.
> >
> > J2EE, huh? Better you than me. ;-)
> >
> > The Arg type that's passed from Yaws to all out/1 functions contains
> > all the headers -- basically it contains everything that's associated
> > with the request. If you want to pass all request info along, the Arg
> > already has it all, so your best bet is to extract what you need from
> > there and pass it along.
> >
> > For example, if you want all the headers but don't want to go through
> > all the trouble of digging through records field-by-field to get them,
> > here's one way to do that within an out/1 function (beware, only
> > partially tested):
> >
> > -define(HEADER_FIELDS, record_info(fields, headers)).
> >
> > hdr_to_string(Hdr) when is_atom(Hdr) ->
> >    lists:map(fun($_) -> $-; (C) -> C end, atom_to_list(Hdr));
> > hdr_to_string(Hdr) when is_list(Hdr) ->
> >    Hdr.
> >
> > out(A) ->
> >    [_|Header_vals] = tuple_to_list(A#arg.headers),
> >    Headers1 = lists:map(fun({Hdr, Val}) ->
> >                                 {hdr_to_string(Hdr), Val}
> >                         end, lists:zip(?HEADER_FIELDS, Header_vals)),
> >    Other = lists:map(fun({http_header, _, K, _, V}) ->
> >                              {hdr_to_string(K), V}
> >                      end, proplists:get_value("other", Headers1)),
> >    Headers = lists:append([proplists:delete("other",
> Headers1), Other]),
> >
> > At this point, Headers will be a proplist of header name string keys
> > and their string values. The special record_info call (which is
> > compile-time only, hence the macro) lets us walk the whole headers
> > record without having to change our code if that record ever changes.
> > Comments on improvements to this approach are most welcomed.
> >
> > --steve
> >
>
>