Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

JSP calls Servlet calls JSP

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had a thought in one of my other posts and wanted to start it's own thread. With the limited JSP/Servlet coding I have done, it seems that there are times when we request a JSP page and time when we request a Servlet. And then JSP pages calls Servlets and Servlets forward to JSP pages.
Well, what if you ALWAYS called a JSP page. So let's say you had
Page1.JSP
Page1.class
The first thing that Page1.JSP page does is call Page1.class. Page1.class does all the initial work that the JSP page might need to do. Like get info from a database, get values for form data, etc. Then it forwards back to the Page1.jsp.
Those familiar with ASP.NET will recognize this a bit. I am just wondering if there would be too much overhead with the extra calls to possibly empty servlets. Or if it would be moot.
Any comments?
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm pretty sure it's a moot point... remember, a compiled jsp page IS a servlet. For small things going from JSP to JSP works fine for me; but on more complex issues, I just find working with a servlet cleaner and neater.
Mark Stein
 
Ranch Hand
Posts: 449
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gregg,
The choice of a MVC/or any other design pattern is a matter of total choice. These design patterns are used to provide a template of solution for a specific problem. No one forces you to use any pattern.
Based on the type of project you are working on the design choice is totally yours provided you consider all possible future aspects of the under consideration project.
Means if you are simply writing code for some test or practice it's easy to call another JSP from one JSP, but should not do that for bigger projects.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do some people still use a JSP page with PURE scriplet code as a Controller or do most people use a Servlet for a controller. I saw an example for the JSP Controller method and thought it was strange.
reply
    Bookmark Topic Watch Topic
  • New Topic