473,506 Members | 13,088 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to set cookies in your browser using java if you are using web service

17 New Member
Hi
i want to know how to set cookies in your browser using java if you are using web service.I have written this code but unable to understand how to set it in the browser

String myCookie = "crowd.token_key="+token;
URL myUrl = new URL("http://localhost:8080/file:///C:/Documents%20and%20Settings/admin/ workspace/ProjectCentral/bin/SdiApp-debug.html");
URLConnection urlConn = myUrl.openConnection();
urlConn.setRequestProperty("Cookie", myCookie);
urlConn.connect();
Sep 4 '07 #1
2 2454
dmjpro
2,476 Top Contributor
Hello.
Follow the Post Guidelines while you do Post.

you can try this one in Jsp.

Expand|Select|Wrap|Line Numbers
  1. <%@page import=java.servlet.http.*%>
  2. <%
  3. Cookie c1 = new Cookie("cookie_name","cookie_value");
  4. response.add(c1);
  5. //you can see the other properties of class Cookie.
  6. %>
  7.  
Best of luck.

Kind regards,
Dmjpro.
Sep 4 '07 #2
mfsiddiq
17 New Member
Hi
Thanks for the quick response,But mine happens to be a web service client so cant use the code provided by you.
Sep 4 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
3175
by: TG | last post by:
This is more of a pain than I thought it would be. I need a simple code segment to determine whether a browser accepts cookies or not. When I pass variables between pages when cookies are turned...
2
3323
by: Amit D.Shinde | last post by:
Hello Experts.. I need some help regarding cookies and session objects and also global.asa file I am creating one cookie when a user logs in on my website. The cookie stores the login name of...
2
2430
by: Lee Wilkie | last post by:
Dear All, I'm new to ASP.NET and have been developing a small app at work to test Forms Authentication. When running on my development machine (using http://localhost/TestApp/Login.aspx for...
3
1815
by: Phillip N Rounds | last post by:
I'm having trouble with using cookies to monitor the stages of login. I have a two stage Registration page ( register.aspx ) and my target page ( MyPage.aspx ) I'm using a cookie named LoginStatus...
12
7739
by: Don Juan | last post by:
I have a simple html document I have been using for some time on my (i.e.) abc.com domain that uses cookies. I recently purchased a new domain name and set up a service to redirect my new domain...
5
13767
by: Jono | last post by:
Hi Everyone, Most tutorials I've seen address cookies from the server's perspective, assuming that the client (usually a browser like Internet Explorer) will manage the persistence. I am faced...
7
2599
by: Control Freq | last post by:
Hi, Apologies of you have heard this many times before, but I don't know if this is a .NET problem or javascript, or something else. I am using IE6 to view pages from a corporate web server...
10
8617
by: TahseenTarafdar | last post by:
Hi, I am updating a Java servlet to store cookies. The class inherits from HttpServlet and overrides the "service" method. Within this method I have the following code to test cookie storing and...
3
2333
by: Shashank | last post by:
Hi all, I am making a http request to a html page residing on a server through a desktop application . The page is actually an html page with some perl queries on the top. For this page I have...
0
7308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7023
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7479
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5617
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5037
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1534
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
410
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.