| Author |
Problem regarding to Cookies with EL, HFSJ pg 386
|
Mukunthan Shanmuganathan
Ranch Hand
Joined: Jul 24, 2007
Posts: 32
|
|
Guys! In order to check cookies with EL I code as follows,but I get "The User is:" and nothing else get printed. Please kind enough to help me to get rid of this. servlet. ------- package com.foo; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class CookieTest extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String name = request.getParameter("name"); Cookie cookie = new Cookie("user",name); response.addCookie(cookie); RequestDispatcher view = request.getRequestDispatcher("result.jsp"); view.forward(request,response); } } result.jsp ---------- <%@ page isELIgnored="false"%> <html> <body> The User is: ${cookie.user.value} </body> </html>
|
Dare to know!
|
 |
Tarun Yadav
Ranch Hand
Joined: Sep 20, 2007
Posts: 134
|
|
Originally posted by Mukunthan Shanmuganathan: String name = request.getParameter("name");
Are you sure you're getting a valid value here? Print it out and check...
|
 |
Mukunthan Shanmuganathan
Ranch Hand
Joined: Jul 24, 2007
Posts: 32
|
|
Dear Tarun Yadav, Yes It does. FYI: Form.html --------- <html> <body> <form method="POST" action="cookieset.do"> User Name: <input type="text" name="name"> <input type="submit"> </form> </body> </html> :roll:
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4726
|
|
|
There's a good chance you had cookies disabled in your browser!
|
A good workman is known by his tools.
|
 |
 |
|
|
subject: Problem regarding to Cookies with EL, HFSJ pg 386
|
|
|