This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

JSP in MVC architecture

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!"
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 !
 
I wish to win the lottery. I wish for a lovely piece of pie. And I wish for a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic