HttpServletrequest usage
Hi everyone,
I am very new to java and I am having problems reading cookies from my browser store.
I am thinking that I have to use the getCookies on HttpServletRequest object. However, I don't know how to initalize this object.
My guess is that the HttpServletRequest object can only be initialized by a jsp. If thats true, is there another way of reading the cookies from my browser store? Below is a smaple piece of code, but I don't know how to test it?
publicvoid doPost
(HttpServletRequest req, HttpServletResponse res){
Cookie[] theCookies = request.getCookies();
if (theCookies !=null){
java.io.PrintWriter out = res.getWriter();
for (int i =0; i< cookies.length; i++){
Cookie aCookie = theCookies<i>;
out.println
("Name : " + aCookie.getName()
+" Value: " + aCookie.getValue());
}
}
}
publicvoid doGet(HttpServletRequest req, HttpServletResponse res){
doPost(req, res);
}
What do code do I write in my main method to call doGet()req, res) method.
Thanks!
moy

