cancel
Showing results for 
Search instead for 
Did you mean: 

iview java set cookie (part II)

holger_stumm2
Active Contributor
0 Kudos

Hi,

after setting the correct classpath, (see previous question) it seems to be ok.

But now I am getting the following error:

...

import javax.servlet.http.*;

....

Cookie SapCookie = new Cookie("MyFirstCookie", "1");

SapCookie.setValue("SAPCook");

response.addCookie(SapCookie);

response.write("Cookie Set: " );

The error in devStudio is:

"The Constructor "Cookie" is undefined"

The example is from

<a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/d1/8cfea3a1e7ff4b953660c5bc437796/frameset.htm">SAP Help Cookie</a>

Is this sample not usable in iviews?

Thanks for answering all my beginner questions so patiently -hs

Accepted Solutions (1)

Accepted Solutions (1)

achim_hauck2
Active Contributor
0 Kudos

Holger,

the error is mysterious. There's definitive such a constructor in the Cookie class (see API documentation).

I can only imagine, that your Cookie object isn't resolved to the correct class. Try to use the full name in your coding:


javax.servlet.http.Cookie SapCookie = new Cookie("MyFirstCookie", "1");

How do your import statements look like?

kr, achim

holger_stumm2
Active Contributor
0 Kudos

Mysterious, indeed.

After deleting and re-pasting the line with "..new.." into DevStudio and re-building, the error disappeared.

Even if the content of the line hasn't changed, it works now. I tried this a dozen times before, always an error.

Sometimes, IT is strange..

Thanks for all your help

regards -hs

Answers (1)

Answers (1)

Former Member
0 Kudos

HI,

if you have added this

"import com.sap.engine.services.webservices.jaxrpc.wsdl2java.soapbinding.Cookie;" import statement

change it to

" import javax.servlet.http.Cookie;"

and Add the jar -> javax.servlet.http.Cookie [servlet.jar]

Then the code works

import javax.servlet.http.Cookie;

import com.sapportals.portal.prt.component.*;

public class Cookie1 extends AbstractPortalComponent

{

public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)

{

Cookie SapCookie = new Cookie("MyFirstCookie", "1");

SapCookie.setValue("SAPCook");

response.addCookie(SapCookie);

response.write("Cookie Set: " );

}

}