473,659 Members | 3,031 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_ke y="+token;
URL myUrl = new URL("http://localhost:8080/file:///C:/Documents%20and %20Settings/admin/ workspace/ProjectCentral/bin/SdiApp-debug.html");
URLConnection urlConn = myUrl.openConne ction();
urlConn.setRequ estProperty("Co okie", myCookie);
urlConn.connect ();
Sep 4 '07 #1
2 2461
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
3183
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 off, the global variables are empty between pages, fine, that tells me cookies store the global variables - right? I store the values in $_session and when cookies are turned on values are passed between web pages - I can see these values in fields...
2
3336
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 the user. I want that cookie should get deleted when user closes the browser without signing out. I think it is done in global.asa file . But i don;t know how to do it?
2
2441
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 example) everything works fine - that is, a successful (authenticated) login grants access to other app pages and the authorization cookie is saved as expected on the local machine. Unfortunately everything turns ugly when trying to 'test' the app...
3
1826
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 to tract the stage of the login process. LoginStatus = "1" denotes that the first part of the login process has been performed. LoginStatus = "2" denotes that the login process has been completed.
12
7765
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 (i.e.) xyz.com to a sub-directory of the abc.com domain. In other words, when someone goes to URL xyz.com, they really end up in abc.com/xyz directory but the MSIE browser says they are xyz.com. The problem is that cookies quit working in this...
5
13784
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 with writing a C#.NET client that uses a web reference to a SOAP web service, and I need to persist the cookies myself, or so it seems. The cookies stored in temporary internet files - accessed each time I hit the web service help page from IE...
7
2608
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 through internet, not VPN. But, the I use a webhop service, so the URL I use is silently redirected to another place. I think this is because the company uses dynamic IP addresses for the server. Anyway, I am trying to use a cookie to remember user...
10
8631
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 retreival: public void service( HttpServletRequest req, HttpServletResponse res ) throws IOException { ...... Cookie cookies = req.getCookies(); if( cookies != null ) {
3
2346
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 some cookies set on my local browser. The content of the page is dependent on the cookie value My problem is that when I make the request through a browser, I am getting the right contents, but when I make request through my desktop application the...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8531
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8628
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
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 we have to send another system
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.