Hi,
I have created two servlet: one will create a cookie (createCookie) and
another is to retrieve the cookie (retrieveCookie). The retrieveCookie will
get the cookie based on the specified cookie name. I placed these servlets
in two different servers.
First of all, I invoke the createCookie servlet to create a cookie from the
server (IP: 192.168.4.90)
And i have checked that there is a update in cookies.txt (Netscape) because
there is a new info which has the 192.168.4.90 as the IP address and so on.
After that, I start the retrieveCookie servlet from another server (IP:
192.168.4.190) which can retrieve that particular cookie.
Then I change the contents of the cookie: 192.168.4.90 to 192.168.4. 190.
I invoke the retrieveCookie again but it can't get that particular cookie.
So, my question is how to get a cookie from a server but that cookie is not
belonged to that server? How to get the IP address from a cookie?
Below is the code of retrieveCookie.java:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class RetrieveCookie1 extends HttpServlet {
public void doGet (HttpServletRequest request,HttpServletResponse
response)
throws ServletException, IOException {
String Name, Value;
Cookie[] cookies = request.getCookies();
for(int i=0; i<cookies.length; i++) {
Cookie thisCookie = cookies[i];
if (thisCookie.getName().equals("User")) {
Name = thisCookie.getName();
Value = thisCookie.getValue();
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>" +
"<head><title> Retrieve Cookie
</title></head>" +
"<strong> Cookie </strong><br>" +
"Name: " + Name + "<br>" +
"Value: " + Value + "<br>" +
"</html>");
}
else {
PrintWriter out = response.getWriter();
out.println("<html>" +
"<head><title>Retrieve
Cookie</title></head>" +
"<strong>Cookie </strong><br></html>");
}
}
}
}
Can anyone help me with this?
Thank You.
"I don't remember how we happened to meet each other.
I don't remember who got along with whom first.
All I can remember is all of us together...always."
Choo Khai Shien, Dominic
---
Disclaimer note:
Confidential information may be contained in the e-mail and any files
transmitted with it ('Message'). If you are not the addressee indicated in
this Message (or responsible for the delivery of this Message to such
person), you are hereby notified that any dissemination, distribution,
printing or copying of this Message or any part thereof is strictly
prohibited. In such a case, you should delete this Message immediately and
advise the sender by return e-mail. Opinions, conclusions and other
information in this Message that do not relate to the official business of
e-BX nor any of its related companies shall be understood as neither given
nor endorsed by e-BX nor any of its related companies.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html