Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

problem with this cookie program, getting a blank output

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



This is my servlet program which retrieves cookies
[ September 04, 2008: Message edited by: Bear Bibeault ]
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


this is my xml file
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i try to retrieve my program



by


http://localhost:8080/allcookie/cookieget

am not getting any output..


am not able to figure out any problem..

allcookie is my project folder..

can anyone help??

i use the tomcat server

am not getting any thing in response in browser.

one more simple cookie program executed . only this one is not excuting... i mean not getting any cookies back to my browser
 
Marshal
Posts: 67416
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you getting no HTML at all sent? Of just an empty body?
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi am getting the header . but the body is empty even though i have cookies stored
 
Bear Bibeault
Marshal
Posts: 67416
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cookies for the domain in which the servlet is executing? The browser will not return cookies for other domains.
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.


how do you retrieve cookies which is stored in our system then??

any other methods?
 
Bear Bibeault
Marshal
Posts: 67416
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't. As I said, cookies will only be delivered to the domain that created them.

What are you really trying to accomplish?
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was just trying to retrieve all cookies from my program just for my knowledge sake!
 
Sheriff
Posts: 9671
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
out.println("<HTML><HEAD><TITLE>");
out.println("Cookie using servlets");
out.println("</TITLE></HEAD></BODY>")

The problem might be in what I have made bold. the body tag here is an ending tag and not starting tag. open the page in a browser, then if you get no output, view the source of the page from the browser. the content might be there but it is not getting displayed...
 
Bear Bibeault
Marshal
Posts: 67416
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. The problem is that one cannot retrieve cookies for any domain except the one that set the cookie. Period.

If you want to see what cookies are stored, use the browser tools provided for that purpose.
 
Ankit Garg
Sheriff
Posts: 9671
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you can set cookies from your own code and then display their values....

for that create cookie objects like Cookie c = new Cookie("name","value"); and then add them to the response like response.addCookie(c);

then the next time you refresh the page, you will get cookie values...
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you want to display cookie then you need to set cookie

example,



Hope This Helps
 
I can't take it! You are too smart for me! Here is the tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic