Article View: borland.public.cppbuilder.internet.web
Article #1320Re: Active Server Object AND response->write???
From: melk
Date: Wed, 23 Mar 2005 20:45
Date: Wed, 23 Mar 2005 20:45
85 lines
3258 bytes
3258 bytes
I just try and It works...
THANKYOU VERY MUCH!!
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> ha scritto nel messaggio
news:4241d051@newsgroups.borland.com...
>
> "melk" <NOSPAMi_melk@libero.it> wrote in message
> news:4241c844@newsgroups.borland.com...
>
> > I just created a Method to write a text into my ASP using
> "response->write"
> > of my IResponse interface but it doesn't work... ?!?!
>
> That is because you are not using it properly.
>
> > m_scriptContext = (IScriptingContext*)AScriptingContext;
> > m_scriptContext->get_Response((IResponse**)&rs);
>
> Why are you retreiving the IResponse interface manually? TASPObject
already
> does that for you, and exposes it via its Response property. You don't
need
> your own OnStartPage() implementation at all.
>
> > tagVARIANT rr;
> > rr.bstrVal = (WideString)"Prova";
> >
> > rs->Write(rr);
>
> That code will not work for several reasons. You did not initialize the
> VARIANT before filling it in. You did not set the VARIANT's vt member to
> VT_BSTR to tell the VARIANT that it contains a BSTR. You are assigning a
> temporary WideString that goes out of scope immediately thus leaving the
> VARIANT pointing to invalid string memory. You did not clean up the
VARIANT
> after using it.
>
> Use something more like the following code instead:
>
> STDMETHODIMP TWEBImpl::Method1()
> {
> try
> {
> VARIANT rr;
> VariantInit(&rr);
> rr.bstrVal = WideString("Prova").Detach();
> rr.vt = VT_BSTR;
> TASPObject::Response->Write(rr);
> VariantClear(&rr);
> }
> catch(const Exception &e)
> {
> return Error(e.Message.c_str(), IID_IWEBImpl, E_UNEXPECTED);
> }
> return S_OK;
> }
>
>
> Which can then be simplied to the following:
>
> #include <utilcls.h>
>
> STDMETHODIMP TWEBImpl::Method1()
> {
> try
> {
> TVariant rr = WideString("Prova");
> TASPObject::Response->Write(rr);
> }
> catch(const Exception &e)
> {
> return Error(e.Message.c_str(), IID_IWEBImpl, E_UNEXPECTED);
> }
> return S_OK;
> }
>
>
> Gambit
>
>
Technical Details
Message-ID:
<4241d58b@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newshub.sdsu.edu!fr.ip.ndsoftware.net!proxad.net!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<4241c844@newsgroups.borland.com> <4241d051@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,455498a15636892c X-Google-Attributes: gidfeeec,public X-Google-Language: ENGLISH,ASCII-7-bit From: "melk" <NOSPAMi_melk@libero.it> Newsgroups: borland.public.cppbuilder.internet.web References: <4241c844@newsgroups.borland.com> <4241d051@newsgroups.borland.com> Subject: Re: Active Server Object AND response->write??? Date: Wed, 23 Mar 2005 21:45:55 +0100 Lines: 87 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1478 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1478 NNTP-Posting-Host: 81.208.118.242 Message-ID: <4241d58b@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1111610763 81.208.118.242 (23 Mar 2005 12:46:03 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newshub.sdsu.edu!fr.ip.ndsoftware.net!proxad.net!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail