Why can't we make jsp as a controller and action
servlet in struts?
Answers were Sorted based on User's Feedback
Answer / aditya sinha
JSP is a part of presentation layer(View in MVC pattern)
which should be decoupled from controller or model, because
of its benifits of flexibility and modularity and focussed
responsibility.
By having the controller separate, we allow to choose the
presentations dynamically. But having them integrated
implies, change in presentation logic may also fiddle with
the controller segment embedded. Any new presentation would
attract unnecessary controller code repetition into it.
More over, if its(the controller segment) only an include
in JSP, then the overhead of JSP parsing to servlet is not
worth doing it.
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / punna
Aording to industry standards Jsp must be "Java ode Less
Jsp". But when it taken controller it must contain java
code to communicate with model components,So we try to take
the java class servlet to plae integration logic
Is This Answer Correct ? | 4 Yes | 3 No |
Answer / srinu
Jsp means "LESS JAVA CODE" and also tag based program.Their
is no tag intigriate with other logic.so jsp is not
suitable for controller.when we take ActionServlet or
Servlet as contoller for suitable.This class contain pure
java code and also intigrate with other logic and follows
oops priniciple,MVC principle.
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / raghu
When JSP compiles, internally the jsp compiler converts the
servlets and compiles servlets java and generartes the
class file. Every time it will do the same thing, so it may
take several time. It may cause performance issue.
Is This Answer Correct ? | 1 Yes | 2 No |
Most of the applications are created in MVC design pattern
to seperate the functions of differnet components and
handle the complexity of applications.
JSP and Servlets are the server side components which can
respond to the client request.
Servlets are the basic components for request handling in
Web Server. They contains pure Java code.
Everything that needs to be done to generate the proper
user response (which is genarally HTML code) needs to be
done through coding. As a single servlet cannot respond
each and every request by itself as client request varies
in type (e.g. enquiry update request add etc) the request
and response object is passed onto different servlets with
little task completed by each servlet.
This controlling part is easier to write in java. So
Servlet is used as controller.
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / amareshara
Becoz in the JSP all only our business logic is described.
but MVC we can all the logic (i.e. B.L.,P.L.) are separated
asap.
Is This Answer Correct ? | 1 Yes | 6 No |
What is double parsedouble in java?
What is backdrop?
What is meant by stack and queue?
is it possible to instantiate the math class?
What is the difference between yield() and sleep()?
What does it mean that a method or field is “static”?
Why Set interface contains unique elements, what internally implemented for this so that it contains unique elements?
How is tree Mirroring implemented?
What is preflight request?
What is a method in coding?
Difference between Application and Applet ?
Why do we override tostring method in java?