[advanced java] Let's Go Shopping!

https://www.codecademy.com/courses/learn-advanced-java/articles/advanced-java-servlets-servlet-project

So I’m stuck on this one step that talks about making the email attribute equal to the email parameter, like I’m trying to figure out how to manifest the email parameter so that I can compare the attribute to whatever the parameter should be.

Here’s my code:

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class AccessServlet extends HttpServlet {
	private UserManager userManager;
	private DatabaseManager db;
	
	private static final long serialVersionUID = 16L;
	
	private void loginAction(HttpServletRequest request, HttpServletResponse response) {
		HttpSession requestGetter = request.getSession(false);
		
		try {
			if (requestGetter != null) {
				if (!request.getParameterMap().containsKey("email")) {
					response.sendRedirect("/catalog/login.html");
				} else {
					if (request.getParameter("email").equals(userManager)) /* i am stuck here */ {
						response.sendRedirect("/catalog/catalog.html");
					} else {
						response.sendRedirect("/catalog/login.html");
					}
				}
			}
		} catch (Exception e) {
			String errorResponse = "Looks like there was an error with the user you tried to log in. Make sure that all the fields in the form have some value and are not empty.";
			response.sendError(HttpServletResponse.SC_BAD_REQUEST, errorResponse);
			return;
		}
	}
	
	@Override
	public void init() {
		db = new DatabaseManager();
		userManager = new UserManager();
	}
}

Also note that I probably got the init() override wrong, but yeah, how do I manifest the email parameter to compare the attribute? I hope I’m not too vague in my asking.

By manifest do you mean you want to get the email parameter from your request object?
If you don’t have access to documentation on this you can run it through a debugger and then inspect the object to see its data members and methods, which should point you in the right direction. At least that’s where I would look at first.

Okay, so basically, I just realized there’s a getAttribute() method alongside the getParameter() method. Now I’m thinking when the Codecademy project says ‘attribute’ it’s talking about getAttribute() whereas ‘parameter’ means getParameter(). Thanks for the help though, since when you said email parameter it made me do a double take and look at the project again, and I saw that it basically said ‘make the attribute equal parameter’ so yeah.

Nice!

It’s still worth it to run things locally and have access to a debugger if you don’t have that set up yet.

Alright, so a new problem has occurred: the getImgAddress() method in CartSummaryHtmlGenerator.java gives me a “cannot find symbol” error. Is there any way to fix this, or should I remove the file temporarily until there’s a fix for it?

So update: I removed the getImgAddress() method and it worked. I still feel like it should have the method working, but I don’t know though.