aspose file tools*
The moose likes JSP and the fly likes Which two of these best? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Which two of these best?" Watch "Which two of these best?" New topic
Author

Which two of these best?

Arun Kumar Gaddam
Ranch Hand

Joined: May 05, 2007
Posts: 58
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

Joined: Nov 08, 2003
Posts: 3479

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

Joined: Oct 06, 2007
Posts: 19
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.


SCJP1.4 (92%), SCWCD (85%), SCBCD (81%), SCEA-I (In Progress)
Arun Kumar Gaddam
Ranch Hand

Joined: May 05, 2007
Posts: 58
Please leave aside the security or performance matters and tell if any other disadvantages about the above...
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

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.


GenRocket - Experts at Building Test Data
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31057
    
232

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


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Sege Stephen
Ranch Hand

Joined: Oct 06, 2007
Posts: 51
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

Joined: Aug 27, 2004
Posts: 328
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Which two of these best?