• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interview question I faced today!  RSS feed

 
Jyoti Vaskar
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Today I faced a question in the interview,
'What if I use jsp as controller & not servlet. Business logic has been proceeded by the model only.
only request & response would be proceeded by jsps & forget about the maintanace,complexity & all.

I answerd like presentation logic would be mixed with the java code which normally is used in servlet which is not good.
But he didnt get satisfied.
Is there any other reason for it?
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36446
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSPs are meant for presentation. While technically one can do anything in a JSP that can be done in a servlet, that doesn't make it wise. This sounds like a question to see if you hold your ground about a bad idea. Or someone who truly doesn't know better.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He might be tested you "whether you are aware of Model1 architecture or not "
 
vijay jamadade
Ranch Hand
Posts: 244
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can say as
first thing is it will be a bad practise.
and yes as jsp gets converted to servlet we can treat it as servlet and do it work as a controller. jsp can do whatever servlet can I think so please correct me.

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vijay jamadade wrote: jsp can do whatever servlet can


No. but vice-versa is true . you cant do below code in Jsp since it use response.getWritter(); implicitly

 
Jyoti Vaskar
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seetharaman venkatasamy wrote:


Hey jsps have response implicit object so I guess we can use above code in jsps as well??
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can always justify using a hammer to bang in a screw if you rationalize enough. it comes down to using the best tool for the job.

 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,
That's the best answer possible. I really liked the analogy.

Regards,
Amit
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!