• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlets or not?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 93
IntelliJ IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear Bibeault, your article was very helpful exactly what I needed.
 
reply
    Bookmark Topic Watch Topic
  • New Topic