• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1902
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure why this thread is in 'Distributed Java'... moving it to the 'JSP' forum.
 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 24309
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic