• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlets or not?

 
sava babo
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, how do you do,

This is my first java topic so forgive me if I don't adhere to forum protocols.

I have been learning Java for some time now and have decided that server side Java is what I want to do.

I have made a few web apps for fun and have just started reading Head First Servlets and JSP where I've just read the mini MVC tutorial.

In a general sense what I see is:

HTTP request to servlet > servlet calls normal Java class for help > servlet then sends the info to a JSP > JSP puts the dynamic info in the right place and is returned to the browser.

It seems like an overly complicated process when I can achieve the same result by:

Http request to JSP > JSP imports normal Java class > JSP can call any method on that class(not just the servlet ones) > JSP puts the info in the right place and is returned to browser.

I know that the first way is better because there is no direct link to the servlet class as it's accessed via the web.xml file. Is that all though?
I like the second way better as I am able to call any method on the standard class rather than go through the doPost or doGet methods.

Please let me know which is better and why.

Thanks.
 
Eduardo YaƱez Parareda
Ranch Hand
Posts: 93
IntelliJ IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd recommend you to use a lightweight MVC framework like the one I have in my signature. It gives you an simple MVC where you won't have to fight with servlets.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sava babo wrote:It seems like an overly complicated process when I can achieve the same result by:

Http request to JSP > JSP imports normal Java class > JSP can call any method on that class(not just the servlet ones) > JSP puts the info in the right place and is returned to browser.

That's been tried -- it's called Model 1 -- and it was a miserable failure.

Please read this article.
 
sava babo
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will check the links out. Thanks for your replies.
 
sava babo
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear Bibeault, your article was very helpful exactly what I needed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!