k***r 发帖数: 4260 | 1 I'm still new to the Java web stuff. I'm just curious,
in Mode 2, a servlet is the entry point of a request, then
it forwards the request to a JSP, then the JSP calls the
beans. I wonder what's the benefit of using a servlet as
the entry point? Can't people just access the JSP? This
way code can still be shared in the beans. |
A**o 发帖数: 1550 | 2 the point is you don't want to put business logics into jsp. you want jsp as
close as it could to be like a html page. |
k***r 发帖数: 4260 | 3 I understand that. But what's wrong with using an HTML
as an entry point? I think a page usually displays some
information (which is what HTML does best), then the
user can take an action (which a bean does best.) So
landing at an HTML/JSP page, and invoke a bean from there
sounds natural to me. I'm still not sure what business
logic has to be done in the page that requires a servlet.
【在 A**o 的大作中提到】 : the point is you don't want to put business logics into jsp. you want jsp as : close as it could to be like a html page.
|
F****n 发帖数: 3271 | 4 Firstly, MVC is only optional. For simple applications you don't need MVC
and you can access control logic just as what you said.
Secondly MVC is a design model. All the benefits is from the designer or
developer's point of view. There's no user benefits nor performance gain (
and sometimes it actually results in performance loss).
Thirdly, the benefits of MVC (more specifically the separation of control
and presentation) are obvious. Just imagine you want a new Web Page for your
site. Because y
【在 k***r 的大作中提到】 : I'm still new to the Java web stuff. I'm just curious, : in Mode 2, a servlet is the entry point of a request, then : it forwards the request to a JSP, then the JSP calls the : beans. I wonder what's the benefit of using a servlet as : the entry point? Can't people just access the JSP? This : way code can still be shared in the beans.
|
k***r 发帖数: 4260 | 5 Thanks for the reply. I think I must be missing something
though. Let's say we have a JSP and a bean in a servlet.
And we don't use a servlet as an entry point instead we
land at the JSP. Isn't that also perfectly separating view
and controller/model?
I think I'm not very clear about the controller rule yet.
It sounds like a dispatch if the first servlet is the controller.
It doesn't really do much, as far as I can see.
To me, the JSP is still the view, and you can have as many
of them as you wa
【在 F****n 的大作中提到】 : Firstly, MVC is only optional. For simple applications you don't need MVC : and you can access control logic just as what you said. : Secondly MVC is a design model. All the benefits is from the designer or : developer's point of view. There's no user benefits nor performance gain ( : and sometimes it actually results in performance loss). : Thirdly, the benefits of MVC (more specifically the separation of control : and presentation) are obvious. Just imagine you want a new Web Page for your : site. Because y
|
A**o 发帖数: 1550 | 6 what are you going to do with the first jsp?
what if you need to db query to populate a table?
what if your behavior is different depending on the people's role?
as Foxman has said, if it's a "simple" application, it's ok whatever you
want to do.
【在 k***r 的大作中提到】 : Thanks for the reply. I think I must be missing something : though. Let's say we have a JSP and a bean in a servlet. : And we don't use a servlet as an entry point instead we : land at the JSP. Isn't that also perfectly separating view : and controller/model? : I think I'm not very clear about the controller rule yet. : It sounds like a dispatch if the first servlet is the controller. : It doesn't really do much, as far as I can see. : To me, the JSP is still the view, and you can have as many : of them as you wa
|
b******y 发帖数: 1684 | 7 huh? why can't it be jsp as entry point?
【在 k***r 的大作中提到】 : I'm still new to the Java web stuff. I'm just curious, : in Mode 2, a servlet is the entry point of a request, then : it forwards the request to a JSP, then the JSP calls the : beans. I wonder what's the benefit of using a servlet as : the entry point? Can't people just access the JSP? This : way code can still be shared in the beans.
|
b******y 发帖数: 1684 | 8 in this case, what's the difference between using jsp and servlet?
using jsp with frameworks like struts2, you can also decouple
business logic from presentation.
【在 A**o 的大作中提到】 : what are you going to do with the first jsp? : what if you need to db query to populate a table? : what if your behavior is different depending on the people's role? : as Foxman has said, if it's a "simple" application, it's ok whatever you : want to do.
|
A**o 发帖数: 1550 | 9 i haven't done struts2 yet. so what do they do in task separation?
【在 b******y 的大作中提到】 : in this case, what's the difference between using jsp and servlet? : using jsp with frameworks like struts2, you can also decouple : business logic from presentation.
|
b******y 发帖数: 1684 | 10 typical MVC based framework, jsp takes care of the view
【在 A**o 的大作中提到】 : i haven't done struts2 yet. so what do they do in task separation?
|
|
|
A**o 发帖数: 1550 | 11 and some kind of weaving involved around jsp was invoked?
【在 b******y 的大作中提到】 : typical MVC based framework, jsp takes care of the view
|
b******y 发帖数: 1684 | 12 not sure what u r talking about.....
but let me try to answer...
basically for the data part, the jsp page would have things like
backendData.field1 |
backendData.field2 |
backendData.field3 |
while the controllers (action class) define where you can the backendData,
for example, SController.execute() would call SBusDelegate.getData()...
what UI framework u use?
【在 A**o 的大作中提到】 : and some kind of weaving involved around jsp was invoked?
|
A**o 发帖数: 1550 | 13 thanks for the example. need further detail like when and how the execute
will be called. but i'll look it up myself if i really need it.
i'm using struts 1.x. used stripes before which was way better than struts 1
.x in my opinion and limited experience. however, you don't always have the
freedom to choose which framework you are going to use. you are picked to
use some framework, mostly. |
b******y 发帖数: 1684 | 14 struts2 tech is more like webwork than struts1
i think it's called struts2 rather than webwork3 due to struts1's popularity.
i used something called burecuda framework before...
it sucks big time. got lost in its event files easily.
1
the
【在 A**o 的大作中提到】 : thanks for the example. need further detail like when and how the execute : will be called. but i'll look it up myself if i really need it. : i'm using struts 1.x. used stripes before which was way better than struts 1 : .x in my opinion and limited experience. however, you don't always have the : freedom to choose which framework you are going to use. you are picked to : use some framework, mostly.
|
g*****g 发帖数: 34805 | 15 This is just basic MVC pattern, and the main benefit being that
you can have multiple views with the same controller and model.
Gmail has an ajax version and a plain html version. Now imagine
you have control logic such as delete a message in the view.
You have to duplicate the code in 2 places. Yes, you can abstract
the shared logic to another class, but any logic may be used
in multiple places in the future. So you end up getting all your
control logic out of your view, and servlet becomes a n
【在 k***r 的大作中提到】 : I'm still new to the Java web stuff. I'm just curious, : in Mode 2, a servlet is the entry point of a request, then : it forwards the request to a JSP, then the JSP calls the : beans. I wonder what's the benefit of using a servlet as : the entry point? Can't people just access the JSP? This : way code can still be shared in the beans.
|
s******e 发帖数: 493 | 16 for a trivial web application, using jsp as the entry point is not a problem
, evetually a jsp will be converted into a servlet anyway.
But for a big web application, even mvc is not enough. if you knew the
histroy, you would know that was the main reason sun introduced view layer
J2ee design patterns such as service to woker, dispatcher... They want you
to avoid the duplicated code and to centralize the cross cutting concerns
such as session management, application level transaction management. |
k***r 发帖数: 4260 | 17 Thanks for all the replies. 偶要消化一下。 |
s******n 发帖数: 876 | 18 maybe you were right and they are wrong.
billions of ASPs and PHPs serve the internet just fine.
【在 k***r 的大作中提到】 : Thanks for all the replies. 偶要消化一下。
|
F****n 发帖数: 3271 | 19 Why you think MVC does not work in ASP or PHP?
【在 s******n 的大作中提到】 : maybe you were right and they are wrong. : billions of ASPs and PHPs serve the internet just fine.
|
s******n 发帖数: 876 | 20 why do you think i think so?
【在 F****n 的大作中提到】 : Why you think MVC does not work in ASP or PHP?
|
|
|
F****n 发帖数: 3271 | 21 Because you use "millions of ASP or PHP" as evidence against MVC.
【在 s******n 的大作中提到】 : why do you think i think so?
|
s******n 发帖数: 876 | 22 no I did not.
【在 F****n 的大作中提到】 : Because you use "millions of ASP or PHP" as evidence against MVC.
|
b******y 发帖数: 1684 | 23 then what did u mean?
【在 s******n 的大作中提到】 : no I did not.
|