Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Harrison Cassedy
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Harrison Cassedy
Java Web Development Techdegree Graduate 12,031 Points

Currently have a problem getting my code to accept usernames and retrieving the input given by the user.

Currently trying to get my course-idea program to run. I noticed thatthe text "what is your username does not appear in the textbox located at localhost:4567. Also whenever a username is typed into the box the website does not display the username. Any info or help would be highly appreciated. https://github.com/casse1hb/course-ideas-spark

1 Answer

In your get method, you need to add the model to your template like this:

        get("/", (req, res) -> {
            Map<String, String> model = new HashMap<>();
            model.put("username" , req.cookie("username"));
            return new ModelAndView(model, "index.hbs");
        }, new HandlebarsTemplateEngine());

instead of:

        get("/", (req, res) -> {
            Map<String, String> model = new HashMap<>();
            model.put("username" , req.cookie("username"));
            return new ModelAndView(null, "index.hbs");
        }, new HandlebarsTemplateEngine());

You also seem to have a typo in several places in your post method: "sing-in" instead of "sign-in".

For the placeholder, I'm not sure why you're not seeing it.