aspose file tools*
The moose likes JSP and the fly likes JSP in MVC architecture Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP in MVC architecture" Watch "JSP in MVC architecture" New topic
Author

JSP in MVC architecture

LakshmiNarayana vishnu
Ranch Hand

Joined: Aug 03, 2006
Posts: 39
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

Joined: Feb 24, 2006
Posts: 6661
    
    5

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 ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

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

Joined: Aug 26, 2006
Posts: 4968
    
    1

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

Joined: Feb 24, 2006
Posts: 6661
    
    5

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 !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP in MVC architecture