• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts MVC Doubt

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Members,

Can anybody tell me that If I am using scriptlet tags in JSP page then it will violate the MVC 2 architecture ? As it is written in MVC 2 that use only tags no single line of java code .

Please help me in removing my doubt.
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know using scriptlets in JSP violets the rule of MVC2, where you heard this buddy, And by the way, the use of scriptlet is forbidden and considered as a bad practice, use minimum or no Java code in JSP, No matter whether its MVC 1, MVC 2 or any other approach
 
Fidel Edwards
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:I don't know using scriptlets in JSP violets the rule of MVC2, where you heard this buddy, And by the way, the use of scriptlet is forbidden and considered as a bad practice, use minimum or no Java code in JSP, No matter whether its MVC 1, MVC 2 or any other approach



That is why I am just asking because Some One taught me that It is not only the bad practice but also the worst one .I am unable to find out any document in support of not using scriptlet tags in jsp .
 
Ranch Hand
Posts: 689
Scala Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi,

If you are looking for description why java code means scriptlet tags in JSP is not a good practice for coding then see the Book Head First - Servlets and JSP - Second Edition in Chapter 8 - Script free Pages Scriptless jsp Read this chapter and get idea why it is bad.


 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ashish Tiwari wrote:
Some One taught me that It is not only the bad practice but also the worst one .


That "some one" taught you correct and you can ask him the reason for same

Ashish Tiwari wrote:
I am unable to find out any document in support of not using scriptlet tags in jsp .


There is no official documents that told us to dont not use scriptlet, there are scriptlet and you can use it, if you want to, but over the years the experience developer found out the problems because of java code in script, so they decided to avoid it and try for some alternatives and that gives the birth to JSTL/EL. Now, this new approach is similar of using tags and easy to use !!
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If scriptlet code contains business logic, then it violates the Model-View-Controller design pattern.

If scriptlet code contains presentation logic related to the View, then it does not violate the pattern.

Another factor is the degree of the violation. If there is one or two pages with scriptlet code (only a few statements) or if there are hundreds of pages with very large scriptlets (hundreds of lines).

Business logic does not go in JSP page files.

Presentation logic does go in JSP page files.
 
Fidel Edwards
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thanks to all for early support !!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic