Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to set Cookies in HTMLPane

    We are trying to set Cookies into HTMLPane

    1. Please find the example in java.net.* API Setting a cookie value in a request:

    Values must be set prior to calling the connect method (http://www.hccp.org/java-net-cookie-...tting_values):

    a. Values must be set prior to calling the connect method:

    URL myUrl = new URL("http://www.hccp.org/cookieTest.jsp");
    URLConnection urlConn = myUrl.openConnection();

    b. Create a cookie string:

    String myCookie = "userId=igbrown";

    c. Add the cookie to a request:
    Using the setRequestProperty(String name, String value); method,
    we will add a property named "Cookie",
    passing the cookie string created in the previous step as the property value.

    urlConn.setRequestProperty("Cookie", myCookie);

    d. Send the cookie to the server:
    To send the cookie, simply call connect() on the URLConnection for which we have added the cookie property:

    urlConn.connect()

    Please let us know how to set in SmartGWT HTMLPane
    HTMLPane eWebHtmlPane = new HTMLPane();
    eWebHtmlPane.setContentsType(ContentsType.PAGE);
    eWebHtmlPane.setContentsURL(WebPageURL);
    Last edited by vnathank; 22 Dec 2013, 23:21. Reason: Updated description

    #2
    We're not sure what the question is here.

    HTMLPane with contentType:"page" is an iframe. If the server sets cookies inside that iframe, they are not normally accessible to the main frame.

    Note that if both frames are in the same domain and set document.domain, it is possible to retrieve the cookies in iframe via JavaScript techniques (this is beyond the scope of this forum - use Google searches to learn about this if interested).

    Comment

    Working...
    X