• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which two of these best?

 
Arun Kumar Gaddam
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.

In an JSP, using an form tag and sending 5 parameters to an session bean and then saving them in DB.

2.

In an JSP, Instantiating an Session Bean and then calling the respective method and saving the five parameters in DB.

I heard that second one has an disadvantage.....but i dont know what it is?
Its an Interview question.Please any one send the reply.

Thanks In Advance.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question is really obfuscated!
The second approach isn't preferable because you have Java code and HTML side by side, which it is a bad thing.
You have to go with MVC pattern (the first choice).
 
vishalraju shah
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First approach is MVC - Model View Controller design pattern , where you separating out your presentation layer.

Second approach is not really good to write code inside JSP for your session bean, here you are violating MVC patterns rule.

Read out few articles about MVC - this will give you clear picture.
 
Arun Kumar Gaddam
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please leave aside the security or performance matters and tell if any other disadvantages about the above...
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Arun Kumar Gaddam:
Please leave aside the security or performance matters and tell if any other disadvantages about the above...


Well, as long as we are throwing away any recommendations for good practices then I guess it doesn't matter how you do it.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34074
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Arun Kumar Gaddam:
Please leave aside the security or performance matters and tell if any other disadvantages about the above...

Harder to read code, harder to maintain code, harder to debug code, going against industry best practices
 
Sege Stephen
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ultimately, your application may fail. As I have done in the past, especially if you require those parameters for your jsp to display the right content. In my case, every time I load the JSP page, nothing happen, if I refresh the page, it worked. Problem was I had all my implementation in the JSP page. Don't do it
 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB fits in Model layer(or a layer which interacts with data i.e.
database),JSP is essentially there for rich web UI.

Calling EJB from JSP is really a bad design.

It makes code hard to debug & maintain.Also, In software development we should design application with entities defined with certain responsibilities. JSP should be used only for "View" i.e. Presentation layer & should not be "Overloaded" with responsibility of "Model"(which inturn talks with data later).

Also, when you mix these layers, application can't be extended with additional features that may come in furure(Requirements are ever changing also people want that applciation should support additional features at variuous stages).

Hope this helps.

Shrinivas
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic