Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can a Page can act as a controller in MVC arch.  RSS feed

 
Vivek Upadhyay
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends ,
I have shortly come across MVC architecture of development.
As per books in MVC servlets act as controller ,Jsp act as presentation part and beans are act as business logic.
I wann to Know Can a JSP page act as controller in MVC architecture,if yes then how....
By:
Vivek Kumar Upadhyay
 
Theodore Casser
Ranch Hand
Posts: 1902
Hibernate Netbeans IDE PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMHO, the answer is "yes, but why would you want to?"

You could do it by simply embedding the appropriate logic in the page in scriptlets. (I assume you're thinking of MVC in terms of having a servlet as the controller usually - if you're going from that paradigm, bear in mind that JSPs are compiled to servlets at runtime.)

Seems easy enough to me, but as I stated above, I'd wonder why you'd want to do it that way - writing a servlet directly, for example, would seem to me to be an easier and more common-sense mechanism to accomplish the MVC structure.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure why this thread is in 'Distributed Java'... moving it to the 'JSP' forum.
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, I think the standard answer I've seen on this site is "sure you can do it, and you can drive in a nail with a wrench too."

-Yuriy
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is with much shame that I confess to actually doing just that in my early J2EE days (before such amenities as Struts and JSF came along).

The results were really horrible. It's as awkward to write, debug, and maintain logic in JSPs as it is to create massive amounts of display tags in a servlet.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!