aspose file tools*
The moose likes JSP and the fly likes a jsp design question... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "a jsp design question..." Watch "a jsp design question..." New topic
Author

a jsp design question...

Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
hi ranchers..
couldn't find any better subject to this post.
I've seen so many web sites URL's like this one:
www.example.com/showProduct.jsp?itemId=300
this example can be extended to other scripting languages like asp, php, perl, python, etc..
I try to design my web applications so that all the connections to the database are performed on servlets,and no jsp pages. But if I, for example, bookmark a web site like this and later on access it again it seems that all these pages are doing the connection to the database in the asp, jsp, php page itself, am I right.???
my question is:
* can I assume that these pages are doing the connection to the database in the JSP page itself?
* or... are they forwarding the request internally to the servlet and then forward it back to the jsp page?
* is this a good idea? I personally think it's bad, according to MVC.


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
LAXMI VEMARAJU
Ranch Hand

Joined: Sep 08, 2001
Posts: 38
hi,
Through jsp you will never connect to database,because they reside on client side, there won't be any security.
The db connection takes place only through servlets or ejb's, it is just your assumption that through jsp's dbconnection is happening.
Through jsp if you connect to database, then it won't be a MVC architecture.
Lakshmi
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Originally posted by LAXMI VEMARAJU:
hi,
Through jsp you will never connect to database,because they reside on client side, there won't be any security.

hhmmm.. on client side?? i do not agree with you Laxmi, could you explain this please ?

The db connection takes place only through servlets or ejb's, it is just your assumption that through jsp's dbconnection is happening.

nope, you can have JSP files full of database code (including the connection itself). But you are right and I agree, this is BAD and it is not MVC architecture
So, are you saying that in this case these jsp files are forwarding the request to the servlet transparently?
thanks
George Joseph
Greenhorn

Joined: Nov 05, 2001
Posts: 24
Originally posted by LAXMI VEMARAJU:
hi,
Through jsp you will never connect to database,because they reside on client side, there won't be any security.
The db connection takes place only through servlets or ejb's, it is just your assumption that through jsp's dbconnection is happening.
Through jsp if you connect to database, then it won't be a MVC architecture.
Lakshmi

Hi Lakshmi,
Jsp's are also executed in server just like servlet or bean. Jsp just processes the logic and send htmls output to the client side. The security issue in case jsp or servlet are all same.
Yes Andres is correct using database connection in JSP is BAD and it is not MVC architecture.
The simplest and the most popular way is all the database connection logic is implemented in JAVA beans and the jsp simply calls the set and get method. For example the showProducts.jsp will be calling a bean say "ShoppingCart" and using the set get methods will add remove items to the bean.
Similarly in Asp also instead of JAVA Beans we have custom made DLL which will contain the Business Logic.
Thus although MVC Architecture is better, but MVC architecture is not compulsory. That is you can have all the request made to JSP page which in turn accesses the required bean and then dispalys the required output.

George Joseph
Transversal E Networks.
LAXMI VEMARAJU
Ranch Hand

Joined: Sep 08, 2001
Posts: 38
Thanks George, thanks for making me right.
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
JSPs ARE Servlets!


James Carman, President<br />Carman Consulting, Inc.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
That�s true, JSPs are just servlets that the WS compiles JIT.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a jsp design question...