File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes JSP ViewHelper DesignPattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "JSP ViewHelper DesignPattern" Watch "JSP ViewHelper DesignPattern" New topic

JSP ViewHelper DesignPattern

Eric Cornely

Joined: Aug 03, 2011
Posts: 9


I'm trying to understand the ViewHelper Design Pattern and i developped a very simple application with a JSP which present a list of student information as a table.

I found different ways of passing data to my view and wonder which one could be the correct implementation of a ViewHelper.

First thing i did was using <jsp:useBean> to access a bean which has a getStudents() method.
The second i tried was creating a servlet which add a "students" attribute to the request than dispatch to the jsp (view).
If I understand the blueprints i could also create a tag library.

What would be the right code to access data and prepare correct Data Transfer Objects in thoses different strategies ?

Until now i thought about direct JDBC connection, DataSource lookup, found a way to lookup a named EntityManager but what would be the best one ?

There could be also the business EJB lookup and then filter data to create DTOs but should give less performance as I would get all information to filter them. I prefer filtering in the query directly. Could'nt my EntityManager be considered in that case as my business tier ?

I know there are lots of possibilities but my concern is finding the best one and/or the one that suites best the blueprint ViewHelper design pattern.

Thank you.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Object-oriented design patterns do not specify a specific implementation. Some patterns may provide examples of what the structure of an implementation may look like, but these are only examples. There is no "right" or "wrong", "incorrect" or "correct".

If you implement a design pattern and the code works and meets the intended requirements, this is good. If the code does not work, this is bad. If you can implement the pattern differently and it works and meets the intended requirements, this is good.

If you have two working implementations and want to decide which one to use, then you must perform analysis on an array of areas to determine which one is "best" for your application. In order to do this effectively and efficiently, you will need experience. You will need to know what to analyze, what information is relevant and what is not, and prior similar experiences.

Good luck!
I agree. Here's the link:
subject: JSP ViewHelper DesignPattern
It's not a secret anymore!