Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP in MVC architecture

 
LakshmiNarayana vishnu
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I am new to struts ad i gt one doubt that
Can a JSP be used as controllor in MVC architecture ? If NO, why ?

Cheers,
Narvish
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP can be used as a controller in the architecture but you shouldnt do that unless you are forced to. You can use the <jsp:forward> standard action to control the flow. The JSP is the view and should care only about presenting the data to the user. What does this have to do with struts though ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64845
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It can I suppose, but it shouldn't. JSP is a templating technology for generating HTML web pages. It's not well suited for processing. Servlets are much better suited for processing.

Use the right tool for the job. A hammer makes a poor screwdriver.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64845
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by John Meyers:
but you shouldnt do that unless you are forced to


I have visions of some wild-eyed and misdirected CTO standing over the staff with a shotgun forcing them to use JSPs for something for which they are a poor choice. "The first person that writes a servlet gets it!"
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSPs should be for view generation. Anything you can do in a Servlet, you can do in a JSP, but can and should are two totally different things.

Here's a good tutorial on MVC, and when to use Servlets as opposed to JSPs:

http://www.technicalfacilitation.com/get.php?link=whatismvc

-Cameron
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have visions of some wild-eyed and misdirected CTO standing over the staff with a shotgun forcing them to use JSPs for something for which they are a poor choice. "The first person that writes a servlet gets it!"


Hehe ! Precisely !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic