• 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

is it a good programming practise to call a jsp from jsp without any servlet?

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone,

In my application i wish to get details from a database table.
So first there is a jsp page on which the user will enter some data and on submission the results will be extracted from the database and displayed to the user in another jsp.

What I did :-

I created a jsp on which the user would enter the details and then on submit there would be an ajax call to a servlet which would retrive the data and those data would be displayed on another jsp page.

What my team membr wants:-

to give a link to another jsp page instead of the servlet in the ajax call. The jsp would have the data retrieved abd displayed to the user.



My question is whether it is a good programming practise to call a jsp from jsp without any servlet? My team mate says that this would reduce the response time to the user.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSPs should not contain business logic (much less access the DB directly), so this would certainly not be a good practice. Plus, the overhead of addressing a servlet and having that forward to a JSP is negligible (compared to having just a JSP) - it will not be measurable compared to networking, processing and rendering times.
 
Raj roy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Ulf....

If i create a pojo class which would have a method that deals with database and invoke those methods using expression language in the jsp then would it make any different or it is the same as haveing the db access code on the jsp??
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a different design, but the difference in performance would again be negligible. I advise to do it right from the beginning, and put a controller (the C in MVC) in the middle.
 
Sheriff
Posts: 67746
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
Read this article for more details.
reply
    Bookmark Topic Watch Topic
  • New Topic