• 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

a jsp design question...

 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks George, thanks for making me right.
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSPs ARE Servlets!
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That�s true, JSPs are just servlets that the WS compiles JIT.
reply
    Bookmark Topic Watch Topic
  • New Topic