4 ms·
I don't do web apps with java, so I honestly don't know if it's the proper way to do it, a satire, or if there is a more straightforward way. Especially, I don
by S4M 12y ago
I don't do web apps with java, so I honestly don't know if it's the proper way to do it, a satire, or if there is a more straightforward way.
Especially, I don't see why one has to write both the class HelloWorldServlet and HelloWorldBean; couldn't one just inherit from one class or implement one interface?
- coldtea 12y agoYou 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).
- smtddr 12y ago>>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 http://guides.rubyonrails.org/layouts_and_rendering.html
- coldtea 12y agoYes, 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.
- maaaats 12y agoThis page sets up an entire framework / java stack containing JEE, with some exampleclasses for stuff that will be needed later. So it's much more than a simple Hello World. Compare it to setting up any other framework: A lot of files and boilerplate configuration.