I was asked to display a cookie that was created in a register.java page to a jsp page that is displayed when a user has registered.

Basically the value of the cookie should display after "Welcome: "

The problem is that every single method I try has some kind of screw up because it's not exactly what's needed.

I have had a really ****ty life lately and can't get my head around this. Would appreciate some help.

The error I'm getting is that it wont find the "Cookiename".getValue()

The method of putting it in the page that I googled wont work. It wont work with a useBean either.

Here's the code:

package download;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

import business.User;
import data.UserIO;

public class RegisterUserServlet extends HttpServlet
    public void doPost(HttpServletRequest request,
            HttpServletResponse response)
            throws IOException, ServletException
        String firstName = request.getParameter("firstName");
        String lastName = request.getParameter("lastName");
        String emailAddress = request.getParameter("emailAddress");
        User user = new User();

        ServletContext sc = getServletContext();
        String path = sc.getRealPath("WEB-INF/EmailList.txt");

        UserIO.add(user, path);
        HttpSession session = request.getSession();
        session.setAttribute("user", user);
        String productCode = (String) session.getAttribute("productCode");
        Cookie emailCookie = new Cookie("emailCookie", emailAddress);
        emailCookie.setMaxAge(60*60*24*365*2); //set its age to 2 years
        emailCookie.setPath("/"); //allow the entire application to access it
        Cookie fnameCookie = new Cookie("fnameCookie", firstName);
        fnameCookie.setMaxAge(60*60*24*365*2); //set its age to 2 years
        fnameCookie.setPath("/"); //allow the entire application to access it
        String url = "/" + productCode + "_download.jsp";
        RequestDispatcher dispatcher =
        dispatcher.forward(request, response);        
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    <title>Murach's Java Servlets and JSP</title>

<h1>List of albums</h1>

  <%@ page language="java" import="business.User"%>
  <%@page import="RegisterUserServlet"%>
   Welcome: <%= fnameCookie.getValue() %>
<a href="<%=response.encodeURL("checkUser?productCode=8601")%>">
    86 (the band) - True Life Songs and Pictures

<a href="<%=response.encodeURL("checkUser?productCode=pf01")%>">
    Paddlefoot - The first CD

<a href="<%= response.encodeURL("checkUser?productCode=pf02")%>">
    Paddlefoot - The second CD

<a href="<%= response.encodeURL("checkUser?productCode=jr01")%>">
    Joe Rut - Genuine Wood Grained Finish