Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes is it a good programming practise to call a jsp from jsp without any servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "is it a good programming practise to call a jsp from jsp without any servlet?" Watch "is it a good programming practise to call a jsp from jsp without any servlet?" New topic
Author

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

Raj roy
Greenhorn

Joined: Jan 11, 2013
Posts: 9
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.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35438
    
    9
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.


Android appsImageJ pluginsJava web charts
Raj roy
Greenhorn

Joined: Jan 11, 2013
Posts: 9
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
Marshal

Joined: Mar 22, 2005
Posts: 35438
    
    9
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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56529
    
  14

Read this article for more details.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: is it a good programming practise to call a jsp from jsp without any servlet?
 
Similar Threads
Model 1 or Model 2 architecture?
don't get latest data from database (JSP / Servlet)
help with methods in jsp
Invoking java layer from JSP
Dynamically adding new information to jsp without scriplets