File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes problem with this cookie program, getting a blank output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem with this cookie program, getting a blank output" Watch "problem with this cookie program, getting a blank output" New topic
Author

problem with this cookie program, getting a blank output

yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120



This is my servlet program which retrieves cookies
[ September 04, 2008: Message edited by: Bear Bibeault ]
yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120


this is my xml file
yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120
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

Joined: Jan 10, 2002
Posts: 61760
    
  67

Are you getting no HTML at all sent? Of just an empty body?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120
hi am getting the header . but the body is empty even though i have cookies stored
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61760
    
  67

Cookies for the domain in which the servlet is executing? The browser will not return cookies for other domains.
yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120
ok.


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

any other methods?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61760
    
  67

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

Joined: Jul 31, 2008
Posts: 120
i was just trying to retrieve all cookies from my program just for my knowledge sake!
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9319
    
  17

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...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61760
    
  67

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

Joined: Aug 03, 2008
Posts: 9319
    
  17

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

Joined: Jan 28, 2008
Posts: 5575

if you want to display cookie then you need to set cookie

example,



Hope This Helps
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with this cookie program, getting a blank output