• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP calls Servlet calls JSP

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Mark Stein
Ranch Hand
Posts: 75
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Vijay S. Rathore
Ranch Hand
Posts: 449
  • 0
  • Mark post as helpful
  • send pies
  • 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
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic