• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with this cookie program, getting a blank output

 
yuvraj kotegar
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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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!
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 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...
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic