Hacker News new | past | comments | ask | show | jobs | submit login

You could just have the servlet write "Hello World" directly.

The Bean is not really useful in the example -- it's mean as a stand in, to know how to write one for your business logic needs, e.g user or product bean etc. (Btw, beans are just lightweight classes used mostly as structs, with getters and setters).




>>You could just have the servlet write "Hello World" directly.

It's been years since I've had to write a Java webapp, but from what I remember using the servlet code to directly write the webpage output was considered bad. That was the job of the jsp file. e.g., "views" in bottlepy and Rails: http://guides.rubyonrails.org/layouts_and_rendering.html


Yes, it was considered bad style because of separation of concerns etc, but nothing necessitated JSP, you could just use servlets and any of tons of template libraries.

And for a hello world, a servlet would do just fine.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: