my dog learned polymorphism*
The moose likes Servlets and the fly likes Disadvantages of servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Disadvantages of servlet?" Watch "Disadvantages of servlet?" New topic
Author

Disadvantages of servlet?

Mandar Khire
Ranch Hand

Joined: Sep 11, 2007
Posts: 492

I read in SL-314 given by sunmicrosystem book
Disadvantage of Servlet
Servlet often contain both business logic & presentation logic.

Explanation: Mixing presentation & business logic means that whenever a web page changes(Which can be monthly or weakly for many applications) the servlets must be rewritten, recompiled, & redeployed.

In JSP also writen same disadvantage.
Disadvantage of JSP
JSP often contain both business logic & presentation logic.

Both Servlet & JSP follows MVC(Model View Controller) pattern using Model 2 architecture ie servlet act the controller, JSP act as the view & java technology classes act as the model.
Why these are disadvantages? What is benefit of separating business logic & presentation logic or Model, view & controller.

& in J2EE platform facilitates an architecture in which the business component are place in separate tier.
my question is in Servlet & JSP why we can not create 3 tier application like J2EE architecture example, Internet client using web browser sends Http Request to web server. In web server, there is web container contains controller. there is another server that is EJB server which contain model. & database is separate. ie i think this is 3tier application.
If using EJB we get security then why people use sevlet & JSP?
Thanks in advance & sorry for asking question wrong way of English.


Millions saw the apple fall, but Newton asked why.
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6


Both Servlet & JSP follows MVC(Model View Controller) pattern using Model 2 architecture ie servlet act the controller, JSP act as the view & java technology classes act as the model.Why these are disadvantages?


Whether servlets and JSP follow the MVC model 2 architecture or not is implementation dependent.I mean as stated above when you mix the business logic with the presentation either in a servlet or a JSP, you are not following the MVC-2.


What is benefit of separating business logic & presentation logic or Model, view & controller.

Obvious better control and maintainable application.

in Servlet & JSP why we can not create 3 tier application

we can create not only three tier but n tier application.


If using EJB we get security then why people use sevlet & JSP?

We do get security using servlet and JSP and also EJB in itself is a heavy weight entity and no one will prefer it for small sized applications.


Hope this helps .


SCJP, SCWCD.
|Asking Good Questions|
Santosh Kolekar
Greenhorn

Joined: Jul 10, 2008
Posts: 6
I read in SL-314 given by sunmicrosystem book

quote isadvantage of Servlet
Servlet often contain both business logic & presentation logic.

In JSP also writen same disadvantage.

quote isadvantage of JSP
JSP often contain both business logic & presentation logic.


Hi Amit,

J2EE application with only jsp and servlets are not pure MVC.
Web container's controller is only mapping request to servlet and giving you respopnse. but when we talk about sepration between Model View and Controller then controler must able to do
1.indepandancy in Model and view it means suppose your servlet name change you need not to go in view means action of html form and change servlet name.& same in vice versa.
2.Request Dispatch it means controller must able to do flexsible dispatch of request & mapping of view.
for ex. if you have J2EE apllication of NetBanking and you want to change it for MobileBanking then same view part does not works.u have to chage it for GUI then your application should allow it without changing Model.
3.Exception,Error Handeling: Controller should be flexible for this.

when such things are there we can say its pure MVC Arcitecture.

These disdvantages is removed in struts framwork.


Santosh Kolekar<br />SCJP,SCWCD,Preparing..SCBCD
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

Hi Santosh Kolekar

J2EE application with only jsp and servlets are not pure MVC.

Why not? its implementation dependent.

These disdvantages is removed in struts framwork.

It is a fact that struts itself uses servlets.
And moreover its a framework.


Hope this helps
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41065
    
  43
If using EJB we get security then why people use sevlet & JSP?

The reason people use servlets/JSPs is not to provide security -although they can do that to a certain degree- but in order to provide web access capability. How would a web browser access an EJB if not through a web app based on servlets and JSPs?


Ping & DNS - my free Android networking tools app
 
jQuery in Action, 2nd edition
 
subject: Disadvantages of servlet?
 
Similar Threads
EJB in struts...
Multi-tier architecture
3 tier architecture
MessageResources VS ResourceBundle
Business Tier + Persistence Tier