We can write any Java Logics in our JSP. Then why we are
using servlets(Controller Layer) to interact with the DAO ?

Answers were Sorted based on User's Feedback



We can write any Java Logics in our JSP. Then why we are using servlets(Controller Layer) to inter..

Answer / sujatha

ya u can write your java logics in scriptlet part of jsp or
u can use jsp action tags to implement the business logic.
but its not the good practice to implement the business
logic in jsp's.mainly the use of jsps is to seperate the
presentation logic and business.. so its better to use
jsps only for presentation purpose..u can write business
logic in action classes or in the servlets..

Is This Answer Correct ?    11 Yes 0 No

We can write any Java Logics in our JSP. Then why we are using servlets(Controller Layer) to inter..

Answer / kaushik

JSPs are translated into Servlets which renders data from
the DAO/Back-End classes on the client page. The job of
Servlet/Servelet Container is to facilitate/give developer
an option to manipulate what servlet container does as well
as use the request/response/session etcetera objects.

Is This Answer Correct ?    3 Yes 1 No

We can write any Java Logics in our JSP. Then why we are using servlets(Controller Layer) to inter..

Answer / ami singh

yes you are right but why we write all the business logic in
jsp ,becuse we just in a first step to follow the mvc
architectuer like in struts so thats why we don't want to
write java code in jsp
we just use jsp for a view and he servlet for the
controller for business logic
oherwise you wan o right all business in jsp so is up to you
noone sop you do this
thanks amit singh
amitsing2008@gmail.com

Is This Answer Correct ?    4 Yes 2 No

We can write any Java Logics in our JSP. Then why we are using servlets(Controller Layer) to inter..

Answer / guest

it reduces coupling so that code changes can be done easily

Is This Answer Correct ?    1 Yes 1 No

We can write any Java Logics in our JSP. Then why we are using servlets(Controller Layer) to inter..

Answer / madhuri

ya u can write your java logics in scriptlet part of jsp or
u can use jsp action tags to implement the business logic.
but its not the good practice to implement the business
logic in jsp's.mainly the use of jsps is to seperate the
presentation logic and business.. so its better to use
jsps only for presentation purpose..u can write business
logic in action classes or in the servlets..

Is This Answer Correct ?    0 Yes 0 No

We can write any Java Logics in our JSP. Then why we are using servlets(Controller Layer) to inter..

Answer / babu

ya u can write your java logic's Jsp or u can use Jsp action
tags to implement the business logic. But if u do like this
your source code may be viewed and used by the others, for
restricting or preventing your source code we are using mvc
architecture like in struts so that's why we don't want to
write java code in Jsp.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is a private class in java?

0 Answers  


take any 4 input numbers. like 2345.. wanted out put is All 16 combinations of the number 2345.. for example- taking input as 4565 output- 5654 4556 4655..

2 Answers   Emphasis,


What are the types of exceptions?

0 Answers  


Is java ee a framework?

0 Answers  


Can a static member function access member variable of an object?

0 Answers   Virtusa,






What is an infinite loop?

0 Answers  


Convert a BST into a DLL and DLL to BST in place.

0 Answers   Amazon,


What is constructor

9 Answers   Manforce, Tech Mahindra,


What is object-oriented programming?

0 Answers  


How does access modifiers work?

1 Answers   Wipro,


Considering notepad/ie or any other thing as process, what will happen if you start notepad or ie 3 times? Where 3 processes are started or 3 threads are started?

0 Answers  


Does java support function overloading, pointers, structures, unions or linked lists?

0 Answers  


Categories